Post Top Ad

Your Ad Spot

Pages

Sunday, 9 February 2020

Display Nth Prime Number


#include<stdio.h>
#include<conio.h>
// NO IS PRIME OR NOT
int Isprime(int no)
{
int i;
for(i=2;i<=no/2;i++)
{
if(no%i==0)
return 0;
}
return 1;
}

void Nthprime(int n)
{
int i;

int count=0;
for(i=2;count<n;i++)
{

if(Isprime(i))
{   count++;

    }
}
printf(" %d",i-1);
}
void main()

   
   Nthprime(10);
}

No comments:

Post a Comment

Post Top Ad

Your Ad Spot

Pages