How to find next prime number? By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.  What is the 10001st prime number?
 A: It is 104743, according to http://primes.utm.edu/lists/small/100000.txt and the related list of the first 10,000 primes ;-)
A: I assume you want to program this? Then the question belongs in a CS forum. However, I will try to motivate how to program this using properties of prime numbers:
1) For a number you could try to divide it by every single positive integer smaller than the respective number (except for 1). This is stupid, as you obviously could just search through the odd numbers (checking 2 first). But can you do even better?
2) Do you have to stop at n-1, or can you stop way earlier? You can. Find out where.
Now count primes.
A: #include <stdio.h>
#include <string.h>

main()
{
    int n,l,h,x,y,p,q;
    printf("enter a number:");
    scanf("%d",&n);
    l=low(n);
    h=high(n);
    q=l-h;
    x=n-l;
    y=h-n;
    p=x-y;

    if(q==0)
        printf("\n This is prime number:%d",n);
    else if(p==0)
        printf("\n The nearest prime numbers are:\n%d\n%d",l,h);
    else if(x<y)
    {
        printf("\n The nearest prime number is:%d",l);
    }
    else 
        printf("\n\n The nearest prime number is:%d",h);

} 

int high(int n)
{
int i,j,k;
 for(i=n;i<=i+1;i++)
 {
     k=0;
     for(j=1;j<=i;j++)
     {
         if(i%j==0)
         {
             k++;

         }     
     }
     if(k==2)
     {
        // printf("%d",i);
         break;
     }

 }
  return i;
}

int low(int n)
{
int i,j,k;
 for(i=n;i>0;i--)
 {
     k=0;
     for(j=1;j<=i;j++)
     {
         if(i%j==0)
         {
             k++;               
         }    
     }
     if(k==2)
     {
         //printf("%d",i);
         break;
     }

 }
  return i;
}

