HI ! FRIENDS
TO FIND NTH PRIME NUMBER:
CODE:
#include <stdio.h>
int main() {
int i,j,c=0,n,range=32767;
int a[100];
int x=0;
scanf("%d",&n);
for(i=2;i<=range;i++)
{
int c=0;
for(j=1;j<=i;j++)
{
if(i%j==0)
{
c++;
}
}
if(c==2)
{
a[x]=i;
x++;
if(x==n)
break;
}
}
printf("%d",a[n-1]);
return 0;
}
HAPPY CODING!!..
Post a Comment