write a c program to print the nth prime number after a given number m
Answers
Answered by
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
Hindi,
1 month ago
Geography,
1 month ago
Math,
1 month ago
Computer Science,
2 months ago
Social Sciences,
9 months ago