Advertisement
AchkataJo

Untitled

Nov 21st, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. #include <stdio.h>
  2. int is_prime(int x)
  3. {
  4. int i,c = 0;
  5. for (i = 1; i <= x; i++)
  6. {
  7. if (x % i == 0)
  8. {
  9. c++;
  10. }
  11. }
  12.  
  13. if (c == 2) {
  14. printf("x is a Prime number");
  15. }
  16. else {
  17. printf("x is not a Prime number");
  18. }
  19. }
  20. int main()
  21. {
  22. int x;
  23. printf("Wirite number ");
  24. scanf("\n%d",&x);
  25. is_prime(x);
  26. return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement