In this tutorial, we are going to make a C Program to checker whether a given number is prime or not with practical program code examples and a step-by-step full explanation.
Program to check prime number or not.
#include<stdio.h>
#include<conio.h>
void main()
{
int input, i, count=0;
printf("Enter any number:");
scanf("%d",&input);
for(i=1; i<=input; i++)
{
if(input%i ==0)
count++;
}
if(count==2)
printf("%d is PRIME Number",input);
else
printf("%d is NOT A PRIME Number",input);
getch();
}