AbdulFathaah

check prime

Sep 26th, 2023
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<conio.h>
  3. void main()
  4. {
  5. int n,i,m,p,flag=0;
  6. clrscr();
  7. printf("Enter the number:");
  8. scanf("%d",&n);
  9. i=2;
  10. do
  11. {
  12. if(n%i==0)
  13. flag=1;
  14. i++;
  15. }
  16. while(i<n/2);
  17. if(flag==1)
  18. printf("%d is not prime\n",n);
  19. else
  20. printf("%d is prime\n",n);
  21. getch();
  22. }
  23. 
Advertisement
Add Comment
Please, Sign In to add comment