#include<stdio.h>
void main()
{
int val,i,n1,n2;
clrscr();
printf("Enter the range:");
scanf("%d%d",&n1,&n2);
printf("\nPrime Numbers between %d and %d are:",n1,n2);
for(val=n1;val<=n2;val++)
{
for(i=2;i<val;i++)
{
if(val%i==0)
{
break;
}
}
if(i==val)
printf("\n%d",val);
}
getch();
}
/*
Output:
Enter the range:99
150
Prime Numbers between 99 and 150 are:
101
103
107
109
113
127
131
137
139
149
*/
void main()
{
int val,i,n1,n2;
clrscr();
printf("Enter the range:");
scanf("%d%d",&n1,&n2);
printf("\nPrime Numbers between %d and %d are:",n1,n2);
for(val=n1;val<=n2;val++)
{
for(i=2;i<val;i++)
{
if(val%i==0)
{
break;
}
}
if(i==val)
printf("\n%d",val);
}
getch();
}
/*
Output:
Enter the range:99
150
Prime Numbers between 99 and 150 are:
101
103
107
109
113
127
131
137
139
149
*/
No comments:
Post a Comment