#include<stdio.h>
main()
{
long int i=0,j=0;
long int n1,n2,t=0,v;
int k;
int flag=0;
printf("\n FROM the number n1 To the number n2 enter the nth prime no you want ");
scanf("%ld %ld %ld",&n1,&n2,&v);
if(v>0&&n2>n1&&n1<1500000&&n2<1500000)
{
for(i=n1;i<=n2;i++)
{
for(j=1,k=0;j<=i;j++)
{
if(i%j==0)
k++;
}
if(k==2)
{
t++;
if(t==v)
{
printf("\n %ld",i);
flag=1;
break;
}
}
}
if(flag==0)
{
printf("\n no prime number is present at this index");
}
}
else
{
printf("Invalid Input");
}
getch();
}
main()
{
long int i=0,j=0;
long int n1,n2,t=0,v;
int k;
int flag=0;
printf("\n FROM the number n1 To the number n2 enter the nth prime no you want ");
scanf("%ld %ld %ld",&n1,&n2,&v);
if(v>0&&n2>n1&&n1<1500000&&n2<1500000)
{
for(i=n1;i<=n2;i++)
{
for(j=1,k=0;j<=i;j++)
{
if(i%j==0)
k++;
}
if(k==2)
{
t++;
if(t==v)
{
printf("\n %ld",i);
flag=1;
break;
}
}
}
if(flag==0)
{
printf("\n no prime number is present at this index");
}
}
else
{
printf("Invalid Input");
}
getch();
}
No comments:
Post a Comment