Sunday, December 23, 2018

PROGRAM TO DISPLAY PRIME NO FROM THE SERIES

/*PROGRAM  TO  DISPLAY  PRIME  NO  FROM  THE  SERIES*/

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

OUTPUT:-
sk.

No comments:

Post a Comment

Wikipedia

Search results

Search The program