Home > Back-end >  C language for help about prime Numbers
C language for help about prime Numbers

Time:10-30

Prime output 1, not 0 to see for a long time don't know where is wrong,,
#include
Int a, I, b=0, c;

Int main (void) {
While (the scanf (" % d ", & amp; A)! EOF)={
C=a/2;
for(i=1; i<=c, a, % I==0. I++) {
B++;
}
If (b==1)
Printf (" 1 \ n ");
If (b> 1)
Printf (" 0 \ n ");
b=0;
}
return 0;

}

CodePudding user response:

While (the scanf (" % d ", & amp; A)!=(EOF), the loop condition so can also be written, then the conditional statements in the for loop that several forms, you can refer to: for (; The expression 1, 2) expression Is given priority to with condition 2; for(; The expression 1 & amp; Expression of 2) Is given priority to with to achieve the condition expression; for(; 2) expression 1 | expression To be achieved after condition expression is given priority to, didn't see anything wrong with overall, this program to let a person see the feel tired

CodePudding user response:

What is your so-called wrong?
Which number is wrong or what do you think of
  • Related