**Print n Prime Numbers in C**

Here, you will get and learn the program code to print n **Prime Numbers in C** programming. You will also understand logic of **Prime number**, **Algorithm**, and **program code** in C language.

## What is Prime number?

A prime number is an integer that is greater than one and only divisible by itself and one. This means, that a prime number cannot be divided by any other number than itself and one.

For example, 2, 3, 5, 7, 11, 13, 17, 19, and 23 are all prime numbers, as they cannot be divided by any other number than themselves and one.

## Algorithm of Prime Number

1. Start with a list of numbers from 2 to some limit.

2. Starting from the first number in the list, check if it is divisible by any other number in the list.

3. If it is divisible, remove it from the list.

4. If it is not divisible, move on to the next number in the list.

5. Repeat steps 2 to 4 until all the numbers in the list have been processed.

6. The remaining numbers in the list will be prime numbers.

## Program to **print n prime numbers in C**** **

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | // Prime Numbers List generate upto n number #include<stdio.h> int main() { int num, i,k,count=0; printf("\nEnter an integer number: "); scanf("%d", &num); for(i=1;i<=num;i++) { for(k=2;k<i;k++) { if(i%k==0) { break; } } if(k==i) { printf("\n%d is prime",i); } } printf("\nTotal Prime Numbers from 1 to %d are %d",num,count); return 0; } |

**Output**

Check out our other C programming Examples