帮忙看下程序有什么问题(编写程序,输入一批正整数(以零或负数为结束标志),求其中的偶数和),#includeint main(void){int number,sum=0;printf("Enter number:\n");scanf("%d",&number);while(number>0){if(number%2==0)sum=sum+number;scanf("%d",number);}printf("Sum=%d\n",sum);return 0;}
问题描述:
帮忙看下程序有什么问题(编写程序,输入一批正整数(以零或负数为结束标志),求其中的偶数和),
#include
int main(void)
{
int number,sum=0;
printf("Enter number:\n");
scanf("%d",&number);
while(number>0)
{
if(number%2==0)
sum=sum+number;
scanf("%d",number);
}
printf("Sum=%d\n",sum);
return 0;
}
答
#includeint main(void){ int number,sum=0; printf("Enter number:\n"); scanf("%d",&number); while(number>0) { if(number%2==0) sum=sum+number; scanf("%d",&number);//你的程序这行错了,输入数据需要加&...