Code Box
----------------------------------------
/* Program to print all prime numbers between a given range of numbers */
#include<iostream.h>
#include<conio.h>
void main()
{
int start,end,i,j,c;
clrscr();
cout<<"\nEnter Start of range:";
cin>>start;
cout<<"\nEnter End of range :";
cin>>end;
cout<<"\n\nPrime Numbers in range are:";
for(i=start;i<=end;i++)
{c=0;
for(j=2;j<start;j++)
{
if(i%j==0)
{
c=1;
}
}
if(c==0)
{
cout<<" "<<i;
}
}
getch();
}
No comments:
Post a Comment