Home > Back-end >  The small white to ask
The small white to ask

Time:10-07

Small white prime want to ask, why is a prime number, such as 11, can output 10, 11 is a prime number, and an 11 is not a prime
#include

Void main () {int m, I, k;
Printf (" both please input a number: ");
The scanf (" % d ", & amp; M);
For (I=2; i<=m; I++) {if I==0) (m % {break; } else {printf (" % d is a prime \ n ", m); }
}
Printf (" % d is not a prime \ n ", m); }

CodePudding user response:

Because you are in for the else print, in the for to print out
For (I=2; iIf (m % I==0) break;
}
If (I==m) printf (" % d is a prime \ "n, m);//on the outside for printing, otherwise only does not meet the if of a for loop will print
The else printf (" % d is not a prime \ "n, m);

CodePudding user response:

The last sentence clearly wrong, anyway, will show this sentence, illogical ah, suggested that get a pen and draw the flow chart, are helpful to improve the ability of programming,

CodePudding user response:

In the last sentence, this code can be a big problem

CodePudding user response:

reference 1st floor qybao response:
because you are in for the else print, in the for to print out
For (I=2; iIf (m % I==0) break;
}
If (I==m) printf (" % d is a prime \ "n, m);//on the outside for printing, otherwise only does not meet the if of a for loop will print
The else printf (" % d is not a prime \ "n, m);
thank you very much

CodePudding user response:

refer to the second floor proorck2019 response:
the last sentence clearly wrong, anyway, will show this sentence, illogical ah, suggested that get a pen and draw the flow chart, are helpful to improve the ability of programming,
ok
  • Related