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.

C Program to Check Prime Number or Not


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();
}


Output

C Program to Check Prime Number or Not