You are on page 1of 2

MOIN UD DEEN

MECAHNICAL ENGINEER

QUESTION:
Write a program that take the highest and lowest
integers from user and find all the possible prime
numbers between them?
PROGRAM:
#include <iostream>
using namespace std;
int main ()
{
int first_num,last_num,i,j;
int count=0;
cout<<"Enter your first num"<<endl;
cin>>first_num;
cout<<"Enter your last num"<<endl;
cin>>last_num;
cout<<"Prime Numbers Between"<<first_num<<"and"<<last_num<<endl;
for(i=first_num;i<=last_num;i++)
{
count=0;
for(j=2;j<i;j++)
{
if(i%j==0)
{
count++;
}
}
if(count==0)
{
cout<<i<<endl;
}
}
system("pause");
return 0;
}
OUTPUT:

You might also like