Advertisement
patryk178

Untitled

Jan 25th, 2021
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int is_prime(int a)
  5. {
  6. if(a<2)return 0;
  7. for(int i=2;i<a;i++)
  8. {
  9. if(a%i==0)return 0;
  10. }
  11.  
  12. return 1;
  13. }
  14.  
  15. int main()
  16. {
  17. int x1;
  18. int x2;
  19. int input = 0;
  20. int count = 0;
  21. printf("Podaj x1=");
  22. input += scanf("%d",&x1);
  23. if(input!=1)
  24. {
  25. printf("Incorrect input");
  26. return 1;
  27. }
  28. printf("Podaj x2=");
  29. input += scanf("%d",&x2);
  30.  
  31. if(input!=2 || x2<x1)
  32. {
  33. printf("Incorrect input");
  34. return 1;
  35. }
  36.  
  37. for(int i=x1;i<=x2;i++)
  38. {
  39. if(is_prime(i))
  40. {
  41. printf("%d ",i);
  42. count++;
  43. }
  44. }
  45.  
  46. if(count==0)printf("Nothing to show");
  47.  
  48. }
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement