11智能在线
新记
6. 编程实现:从键盘输入若干个正整数,求其中所有偶数的和并输出。输入的数以0作为结束标记。(思考
6. 编程实现:从键盘输入若干个正整数,求其中所有偶数的和并输出。输入的数以0作为结束标记。(思考C语言编程
举报该文章
相关建议 2018-01-12
#include <
stdio.h
>
int main()
{
int num=0,total =0;
do{
scanf("%d",&num);
if (num%2==0)
{
total += num;
}
}while (num!=0);
printf("total is [%d]\n",total);
return 0;
}
1
2
3
4
5
6
7
8
9
0
total is [20]
温馨提示:内容为网友见解,仅供参考
当前网址:
https://11.t2y.org/zz/fvfq2m72p4fv2s2p274.html
其他看法
无其他回答
相似回答
大家正在搜
相关问题
编程实现:从键盘录入若干整数,当输入0时结束录入,计算并输出...
编程:实现从键盘输入一个整数n,并计算0到n间的所有偶数和。...
用VFP编写程序:从键盘输入一个正整数,然后求1到该数范围之...
麻烦看看啦c语言:编程从键盘上输入若干正整数,求其中最大数和...
编程输入若干个正整数,统计其中奇数和偶数的个数,直到输入–1...
求一c语言程序:输入一批正整数(以0或负数为结束标志)求其中...
c语言,从键盘输入若干个整数,用-1作为输入结束的标志,求他...
输入若干个正整数,当输入0或者负数时结束,要求计算这若干个正...