Below is a simple C program that takes a range as input from the user and displays all the prime numbers within that range.
Program :
#include<stdio.h>
#include<conio.h>
int main ()
{
int i, prime, up, low, n;
printf (“Enter the Lower limit : “);
scanf (“%d”, &low);
printf (“Enter the Upeer limit : “);
scanf (“%d”, &up);
if(low>=2)
{
printf (“Prime Numbers are : “);
for (n=low;n<=up;n++)
{
prime = 1;
for (i=2;i<n/2;i++)
if (n%i==0)
{
prime = 0;
break;
}
if (prime)
printf (“\t %d”, n);
}
}
else
{
printf(“Enter lower number must be greater than 1”);
}
}