#include <iostream.h>
#include <conio.h>
int main()
{
clrscr();
int n_div;
int num1,num2;
int divisor;
cout<<"Enter starting number: ";
cin>>num1;
cout<<"Enter ending number: ";
cin>>num2;
cout<<"\n";
cout<<"Prime numbers are: ";
while(num1<=num2)
{
divisor=1;
n_div=0;
while(divisor<=num1)
{
if(num1%divisor==0)
{
n_div++;
}
divisor++;
}
if(n_div==2)
{
cout<<num1<<" ";
}
num1++;
}
getch();
return 0;
}
0 comments:
Post a Comment