# C Program to Generate First 50 Prime Numbers

A Prime Number is a positive integer greater than 1 which is divisible by 1 and itself. In other words, Prime number is a whole number greater than whose factors are 1 and itself. Examples of first few prime numbers are 2, 3, 5, 7, 11, 13..

In this C program, we are going to generate first 50 such prime numbers. Keep in mind that first prime number is 2 and which is only even prime number.

## Program

``````
#include<stdio.h>
#include<conio.h>

int main()
{

int count=1, flag, i=2, j;
clrscr();

/* Generating prime numbers */
printf("First 50 Prime Numbers Are: \n");
while(count <= 50)
{
flag = 0;
for(j=2; j <= i/2; j++)
{
if(i%j==0)
{
flag=1;
break;
}
}
if(flag==0)
{
printf("%d\t",i);
count++;
}
i++;
}
getch();
return(0);
}
``````

Output of the above program :

```First 50 Prime Numbers Are:
2    3     5    7    11   13   17   19   23   29
31   37    41   43   47   53   59   61   67   71
73   79    83   89   97   101  103  107  109  113
127  131   137  139  149  151  157  163  167  173
179  181   191  193  197  199  211  223  227  229
```