Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Program to print prime numbers
- #include <stdio.h>
- #include <stdbool.h>
- int main ()
- {
- int p, d;
- _Bool isPrime;
- for ( p = 2; p <= 50; ++p ) {
- isPrime = 1;
- if (p!=2 && p%2==0){
- isPrime = 0;
- }else{
- for ( d = 3; d < p/2; d+=2 )
- if ( p % d == 0 )
- isPrime = 0;
- }
- if ( isPrime != 0 )
- printf ("%i ", p);
- }
- printf ("\n");
- return 0;
- return 0;
- }
Advertisement
RAW Paste Data
Copied
Advertisement