
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int n,k,i=1,j,b=2,last,flag=1,s=0;
int* a;
clrscr();
printf("Program to find nth prime number");
printf("\nEnter the value of n:");
scanf("%d",&n);
a=(int*)malloc(n*sizeof(int));
while(i<=n)
{
k=sqrt(b);
for(j=2;j<=k;j++)
{
if(b%j==0)
{
flag=0;
break;
}
else
flag=1;
}
if(flag==1)
{
a[s]=b;
printf("%d",a[s]);
last=s;
s=s+1;
i++;
}
b++;
}
printf("\n%dth prime number is =%d",n,a[last]);
getch();
}