In this tutorial, we are going to write a program in C to print the first N Prime Number. Basically, on the basis of the given input, our program will print the Prime Number.

For example, if we want to print the first 5 prime numbers, Our program will take 5 as an input and it will print 2,3,5,7,11 as an output.

## What is Prime number?

A prime number is a number that can only divide by 1 and the number itself.

for example, 2, 3, 5 etc are the prime number. Here 2 and 3 can only be divided by 1 and number itself.

But 4 or 6 is not a prime number because 4 can be divided by 2 and 6 can be divided by 2 and 3.

Let’s see the program in C

## C Program to Print first n Prime Number

```
#include<stdio.h>
void main() {
int i = 0, n, temp, temp1 = 1;
printf("Please give input a number: ");
scanf("%d",&n);
printf("Prime numbers Upto %d are \n",n);
while (temp1<=n) {
temp = 0;
for (i=2;i<=(temp1/2); i++) {
if (temp1%i==0) {
temp = 1;
break;
}
}
if (temp == 0)
printf("%d \n",temp1);
temp1++;
}
}
```

**Output**

```
Please give input a number: 26
Prime numbers Upto 26 are
1
2
3
5
7
11
13
17
19
23
```

## Also Prepare Below Important Question

- Python Program to add two number using Recursion
- Python Program to Find Highest Frequency Element in Array
- Python Program to Merge two Arrays
- Perform left rotation by two positions in Array Using Python
- Python Program to Delete Element at Given Index in Array
- Python Program to Delete element at End of Array
- Python Program to Copy one String to Another String
- Python Program to Remove Repeated Character from String
- Print highest frequency Character in String in Python
- Python Program to Convert lowercase vowel to uppercase
- Convert Celsius to Fahrenheit in Python
- Leap Year Program in Python
- Python Program to convert Decimal to Octal number
- Python Program to Convert Decimal Number into Binary
- Find all Pairs Whose Sum is Equal to Given number in Python
- Python Program to Replace First Vowel With ‘-‘ in String
- Python Program to find Prime factors of given integer
- Python Program to Print Prime Number in given range
- Java Program to Perform Left Rotation on Array Elements by Two
- Java Program to Perform Right Rotation on Array Elements by Two

## Interview Questions Categories

### C Programming Interview Preparation

### Core Java Programming Interview Preparation

- Core Java Programming Coding Questions
- Core Java Pattern Programming Questions
- Core Java Programming Interview Questions