Advertisement
saira12tabassum19

Untitled

Jul 1st, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.64 KB | None | 0 0
  1.     #include<stdio.h>
  2.      
  3.     int main()
  4.     {
  5.        int n, i = 3, count, c;
  6.      
  7.        printf("Enter the number of prime numbers required\n");
  8.        scanf("%d",&n);
  9.      
  10.        if ( n >= 1 )
  11.        {
  12.           printf("First %d prime numbers are :\n",n);
  13.           printf("2\n");
  14.        }
  15.      
  16.        for ( count = 2 ; count <= n ;  )
  17.        {
  18.           for ( c = 2 ; c <= i - 1 ; c++ )
  19.           {
  20.              if ( i%c == 0 )
  21.                 break;
  22.           }
  23.           if ( c == i )
  24.           {
  25.              printf("%d\n", i);
  26.              count++;
  27.           }
  28.           i++;
  29.        }
  30.      
  31.        return 0;
  32.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement