/*to find the largest prime number below 5000*/
#include<stdio.h>
#include<math.h>
void
main()
{
int
n,i,remainder,d,c=0;
for(n=5000;n>=3;n--)
{
d=sqrt(n);
for(i=2;i<d;i++)
{
remainder=n%i;
if(remainder==0)
goto label;
}
if(n>c)
c=n;
}
label:;
}
printf("the
largest prime number %d is\n",c);
}
Result:
the largest prime number 4999 is
Press any key to continue