当前位置:网站首页>Use the while loop to calculate the odd and even sums in 1-100 [method 1]
Use the while loop to calculate the odd and even sums in 1-100 [method 1]
2022-06-21 22:17:00 【Programming expert】
【 Title Description 】
utilize while loop , Separate calculation 1-100 Sum of odd numbers in 、 An even sum .
The code is as follows :
notes : Code for reference only , There is not only one solution .
//while loop 【 Method 1 】
#include<iostream>
using namespace std;
int main(){
int i=1,sum1=0,sum2=0;
while(i<=100) {
if(i%2==0) sum1=sum1+i;else sum2=sum2+i;i++;}
cout<<"sum1="<<sum1<<" sum2="<<sum2;
return 0;
}
边栏推荐
- Worthington collagenase raw material
- Beijing accelerates ecological construction, Medtronic Internet and Moore thread complete product compatibility and mutual certification
- 类库、框架、模块、组件等概念介绍
- Chess and card games
- Instadeep ltd:arthur flajolet | group based rapid reinforcement learning on a single machine
- Six interesting web page effects that can be used
- PAML|计算dN/dS值的生信软件
- 基于OpenCVSharp的001新建工程项目
- Thoroughly understand the foundation of MySQL: the difference between B tree and b+ tree
- 刷题笔记(十六)--二叉树:修改与构造
猜你喜欢

Instadeep ltd:arthur flajolet | group based rapid reinforcement learning on a single machine
![洛谷P1514 [NOIP2010 提高组] 引水入城 题解](/img/62/6bab87231074b87770e90257ef7bbc.jpg)
洛谷P1514 [NOIP2010 提高组] 引水入城 题解

弗吉尼亚大学:Ingy ElSayed-Aly | 多智能体强化学习中的基于逻辑的奖励形成

Chess and card games

Lifting method (Part 2) lifting tree

Paml| Shengxin software for calculating dn/ds value

leetcode刷题:顺丰科技智慧物流校园技术挑战赛

Supplier management system of digital commerce cloud Paper Group: promote enterprise information construction and comprehensively improve supplier management efficiency

Does the whole house smart home brand "zhiting technology" have an experience center?

Dotter| dot method sequence pairwise comparison software
随机推荐
Anaconda添加channels
Font size in DataGridView of C #
处理订单业务多面手,订货管理系统实现企业订货库存统一管理
传承百年经典的瑞吉管家静待您的优雅旅程再次开启
Advanced packaging, the beginning of a big cycle -- a symposium on semiconductor equipment
博图仿真HMI与真实1200PLC通讯失败
How to associate the QR code of wechat applet to realize the integration of two codes
类库、框架、模块、组件等概念介绍
Shell脚本简单语法
I2C【2】-IIC为什么需要用开漏输出和上拉电阻bug
【深入理解TcaplusDB技术】Tmonitor系统升级
Enzo high sensitivity detection Arg8 vasopressin ELISA Kit
Worthington木瓜蛋白酶特异性和应用
利用do while循环,分别计算1-100中奇数的和、偶数的和【方法二】
Self made C compiler
How to write the title of popular popular items in our media video
自制C#编译器
Luogu p1514 [noip2010 improvement group] water diversion into the city
B2B mall website helps enterprises speed up distribution and build an efficient and intelligent B2B online distribution platform
洛谷P1514 [NOIP2010 提高组] 引水入城 题解