Home > Back-end >  Why this code cannot read 10.
Why this code cannot read 10.

Time:01-24

Why even when the code read 10, not included in the even number?
 # include 
# define STOP 0
Int main (void)
{
Int ch;
Int odd=0, even=0;
Int sum_odd=0;
Int sum_even=0;

Scanf_s (" % d ", & amp; Ch);
While (ch!=STOP)
{
If (ch=='\ n') {
Scanf_s (" % d ", & amp; Ch);
continue;
}
Else if (ch % 2==0) {
Even++;
Sum_even +=ch;
}
The else {
Odd++;
Sum_odd +=ch;
}
Scanf_s (" % d ", & amp; Ch);
}
Printf (" Odd number is % d, and which business is % d. \ nEven business is % d, and which business is % d ",
Odd, sum_odd/odd, even, sum_even/even);

return 0;
}

CodePudding user response:

Because '\ n' is 10, 10 is that if you input intercepted,
  • Related