Friday, July 1, 2022
HomeUncategorizedprime number problem in c programming

prime number problem in c programming

#include<stdio.h>
 
int main()
{
int n, i = 3, count, c;
 
printf("Enter the number of prime numbers requiredn");
scanf("%d",&n);
 
if ( n >= 1 )
{
printf("First %d prime numbers are :n",n);
printf("2n");
}
 
for ( count = 2 ; count <= n ; )
{
for ( c = 2 ; c <= i - 1 ; c++ )
{
if ( i%c == 0 )
break;
}
if ( c == i )
{
printf("%dn",i);
count++;
}
i++;
}
 
return 0;
}
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

CSAT FORMULA BOOK

Only IAS Current Affairs

What is a Polynomial?