Guest User

Untitled

a guest
Jul 21st, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. 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. }
Add Comment
Please, Sign In to add comment