SAADQUAMER

Number is Prime number or not

Jun 21st, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.32 KB | None | 0 0
  1. // C program to check whether a number is Prime number or not.
  2. #include<stdio.h>
  3. int main(){
  4.  
  5. int x,count=0,i;
  6. printf("Enter a number :");
  7. scanf("%d",&x);
  8. for(i=2;i<x;i++)
  9. if(x%i==0){
  10. count++;
  11. break;}
  12.  
  13. if(count==0)printf("%d is Prime Number\n",x);
  14. else printf("%d is not a Prime number\n ",x);
  15.  
  16.  
  17.  
  18.  
  19. return 0;}
Advertisement
Add Comment
Please, Sign In to add comment