Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int is_prime(int a)
- {
- if(a<2)return 0;
- for(int i=2;i<a;i++)
- {
- if(a%i==0)return 0;
- }
- return 1;
- }
- int main()
- {
- int x1;
- int x2;
- int input = 0;
- int count = 0;
- printf("Podaj x1=");
- input += scanf("%d",&x1);
- if(input!=1)
- {
- printf("Incorrect input");
- return 1;
- }
- printf("Podaj x2=");
- input += scanf("%d",&x2);
- if(input!=2 || x2<x1)
- {
- printf("Incorrect input");
- return 1;
- }
- for(int i=x1;i<=x2;i++)
- {
- if(is_prime(i))
- {
- printf("%d ",i);
- count++;
- }
- }
- if(count==0)printf("Nothing to show");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement