Arnab_Manna

Prime.c

Jun 14th, 2021 (edited)
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.44 KB | None | 0 0
  1. #include <stdio.h>
  2. int isPrime(int x)
  3. {
  4.     int c = 0;
  5.     if (x == 0 || x == 1)
  6.         return 0;
  7.     for (int i = 2; i < x; i++)
  8.     {
  9.         if (x % i == 0)
  10.             c++;
  11.     }
  12.     if (c == 0)
  13.         return 1;
  14.     else
  15.         return 0;
  16. }
  17.  
  18. void main()
  19. {
  20.     printf("PRIME NUMBERS LESS THAN 100 ARE : \n");
  21.     for (int i = 0; i < 100; i++)
  22.     {
  23.         if (isPrime(i) == 1)
  24.             printf("%d\n", i);
  25.     }
  26. }
Add Comment
Please, Sign In to add comment