Math, asked by shatakshi9876, 2 months ago

write a c program to print the nth prime number after a given number m​

Answers

Answered by gudelahima
4

Answer:

Step-by-step explanation:

#include <stdio.h>

#include<math.h>

int

main ()

{

 int rangenumber, c = 0, num = 2, i, letest = 0;

 printf ("Enter Nth Number\n");

 scanf ("%d", &rangenumber);

 while (c != rangenumber)

   {

     int count = 0;

     for (i = 2; i <= sqrt (num); i++)

{

  if (num % i == 0)

    {

      count++;

      break;

    }

}

     if (count == 0)

{

  c++;

  letest = num;

}

     num = num + 1;

   }

 printf ("%dth prime number is %d ",rangenumber,letest);

 return 0;

}

Similar questions