#include <stdio.h>
int main()
{
int n1, n2, i, j, flag;
printf("Enter two numbers(interval) : ");
scanf("%d %d", &n1, &n2);
printf("Prime numbers between %d and %d are: ", n1, n2);
for (i = n1 + 1; i < n2; ++i)
{
flag = 0;
for (j = 2; j <= i / 2; ++j)
{
if (i % j == 0)
{
flag = 1;
break;
}
}
if (flag == 0)
printf("%d ", i);
}
return 0;
}
Enter two numbers(interval) : 10 100
Prime numbers between 10 and 100 are: 11 13 17 19 23 29 31 37 41 43 47 53 59 61
67 71 73 79 83 89 97
No comments:
Post a Comment