# C Program to Find Prime Numbers in a Given Range

C program can help to find the mathematic operation like prime number. Here is an code on C program to learn and understand the code behind

Definition:

Prime numbers are the positive integers having only two factors, 1 and the integer itself. 3 is a prime number, but 4 is not a prime number it is a composite number. The factors of 4 are 1, 2, and 2 but the factors of 3 is 1, hence 3 is a prime number.

Program to find prime number in a given range,

``````#include<stdio.h>
#include<conio.h>
void main()
{
int n,num,i;
printf ("Enter the last number : ");
scanf("%d", &n);
printf("The Prime Numbers are...");
for(num=1;num<=n;num++)
{
for(i=2;i<num;i++)
{
if(num %i ==0)
break;
}
if(num==i)
{
printf("%d\t",num);
}
}
getch();
}
``````

Output:

``````Enter the last number : 100
The 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``````