循环输入整数,直到0为止,求输入的奇数个数和偶数个数
#include<stdio.h>
int main()
{
int a;
int even=0;
int odd=0;
printf("please enter an integer and end with 0\n");
while(1){
scanf("%d",&a);
if(a==0)
break;
if(a%2 == 1){
odd++;
}else{
even++;
}
}
printf("The number of odd Numbers is: %d,\nThe number of even Numbers is: %d\n",odd, even);
return 0;
}