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();
}
Learn More :
Prime Number
- PRINT PRIME NUMBERS BETWEEN 1-300 USING BREAK AND CONTINUE IN C
- Check given number is prime number or not using c program.
- C Program to Check Prime Use Loop And Recursive
- C or C++ Program To Print Prime Number
- C Program For Prime Number or Not
- C Program For Prime Number Using Function
- C Program For Prime Number
- Huge Prime in C Program
- C Program to Detection of a Prime Number
- C Program to print all prime numbers from 1 to 300.
- C Program To Find Prime Number And If Number Is Not Prime Then Find Factors
- C Program to Find Prime Number and Complex Number
- C Program to accept n numbers & store all prime numbers in an array & display this result