#include <iostream>
using namespace std;
int main()
{
int n;
cout<<"Input integer for n: ";
cin>>n;
int prime=0;
int count,count1=0;
for(int x=1;;x++){
count1=0;
for(int y=1;y<=x;y++)
{
if(x%y==0)
{
count1++;
}
}
if(count1==2)
{
count++;
prime=x;
}
if(count==n)
{
break;
}
}
cout<<"Prime number is "<<prime<<endl;
return 0;
using namespace std;
int main()
{
int n;
cout<<"Input integer for n: ";
cin>>n;
int prime=0;
int count,count1=0;
for(int x=1;;x++){
count1=0;
for(int y=1;y<=x;y++)
{
if(x%y==0)
{
count1++;
}
}
if(count1==2)
{
count++;
prime=x;
}
if(count==n)
{
break;
}
}
cout<<"Prime number is "<<prime<<endl;
return 0;
}
OUTPUT:
Comments
Post a Comment