Program To Find Nth Prime Number And Print On The Screen.
"Nice One Program"
#include<iostream.h>
#include<conio.h>
int main()
{ clrscr();
int i,j,f=1,c=1,n,a[1000];
a[0]=2;
for(i=3;i<=1000;i++)
{ for(j=2;j<i;j++)
{ if(i%j==0)
{ f=0;break;}
}
if(f)
a[c++]=j;
else
f=1;
}
cout<<"\nEnter which prm numbr:";
cin>>n;
cout<<a[n-1];
getch();
}
"Nice One Program"
#include<iostream.h>
#include<conio.h>
int main()
{ clrscr();
int i,j,f=1,c=1,n,a[1000];
a[0]=2;
for(i=3;i<=1000;i++)
{ for(j=2;j<i;j++)
{ if(i%j==0)
{ f=0;break;}
}
if(f)
a[c++]=j;
else
f=1;
}
cout<<"\nEnter which prm numbr:";
cin>>n;
cout<<a[n-1];
getch();
}
No comments:
Post a Comment