#include <stdio.h>
int isPrime(int num) {
if(num <= 1)
return 0;
for(int i = 2; i < num; i++) {
if(num % i == 0)
return 0;
}
return 1;
}
int main() {
int start, end;
printf("Enter two numbers (intervals): ");
scanf("%d %d", &start, &end);
printf("Prime numbers between %d and %d:\n", start, end);
for(int i = start; i <= end; i++) {
if(isPrime(i))
printf("%d ", i);
}
return 0;
}
Enter two numbers (intervals): 10 20
Prime numbers between 10 and 20:
11 13 17 19

About the authorSai Kishore Randhi
Embedded systems, VLSI, and chip design
Sai Kishore writes about embedded systems, VLSI, chip design, and the programming concepts behind modern hardware.
View LinkedIn profile ↗