C examples for Statement:for
Generate a table of prime numbers, using bool type
#include <stdio.h> #include <stdbool.h> int main (void) { int p, d;/*from w w w. j a v a2s. co m*/ bool isPrime; for (p = 2; p <= 50; ++p) { isPrime = true; for (d = 2; d < p; ++d) if (p % d == 0) isPrime = false; if (isPrime != false) printf ("%i ", p); } printf ("\n"); return 0; }