How to write a C Program to print Prime Number From a Given Value (50) in C Programming Language ?
Solution For C Program:
// To print 50 prime numbers from given value
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
main()
{
int i,j,c=0,n;
printf("Enter the first value\n");
scanf("%d",&n);
printf("The First 50 Prime Numbers from given value are:");
for(i=n;i<=n+200;i++)
{
for(j=2;j<=i;j++)
{
if(i%j==0)
break;
}
if(j==i)
{
c++;
printf("\t%d",i);
}
if(c>50)
break;
}
getch();
}