Mahmud33

check whether a number is Prime number or not

Jun 30th, 2019
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.35 KB | None | 0 0
  1. #include <stdio.h>
  2. int main()
  3. {
  4.     int n,i,c=0;
  5.     scanf("%d", &n);
  6.     for(i=1;i<=n;i++)
  7.          {
  8.          if(n%i==0)
  9.          {
  10.           c++;
  11.          }
  12.         }
  13.          if(c==2)
  14.          {
  15.             printf("Prime number");
  16.          }
  17.         else
  18.         {
  19.             printf("Not a Prime number");
  20.         }
  21.     return 0;
  22. }
Add Comment
Please, Sign In to add comment