Display Prime Numbers On a Given Range
#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,t;
clrscr();
printf("\n Enter The Range From 1 to : ");
scanf("%d",&t);
printf("\n Prime Numbers in the Range 1-%d :\n\n ",t);
for(n=1;n<=t;n++)
{
for(i=2;i<=n-1;i++)
{
if(n%i==0)
{
break;
}
}
if(n==i)
printf(" %d",n);
}
getch();
}
Output :
- Following are the prime numbers from 1-100.
In this way we, we can find prime numbers on given range and display them on the screen.


