Home > database > Passing the man can help me to look at the code have what problem
Passing the man can help me to look at the code have what problem
Time:09-20
#include #include #include
Int main () { Int j, I, a, b; a=0; B=0; Srand ((unsigned) (time (NULL))); for(j=0; J<100; J++) { I=rand () % 11; Printf (" % d ", I); } If (I % 2==0) B++; The else a++; { Printf (" odd number is % d, the even number is % d ", a, b); } return 0; } Why the 100 number is there, as a result, it says odd one even zero
CodePudding user response:
You have the wrong place, brackets only + was over, b++ A little change:
# include & lt; stdio.h> #include #include
Int main () { Int j, I, a, b; A=0; B=0; Srand ((unsigned) (time (NULL))); For (j=0; J & lt; 100; J++) { I=rand () % 11; Printf (" % d \ n ", I);
If (I % 2==0) B++; The else a++; } { Printf (" odd number is % d, the even number is % d ", a, b); } return(0); }