Prime Number program in C | C program to test whether given number is prime or not

Spread the love
/************ Program ************/
#include<stdio.h>
main()
{
int n,i,cnt=0;
printf(“Enter any Number : “);
scanf(“%d”,&n);

for(i=1;i<=n;i++)
{
if(n%i == 0)
cnt++;
}

if(cnt == 2)
{
printf(“Given Number is Prime Number n”);
}
else
{
printf(“Not Prime Number n”);
}
}

/********* OUTPUT ********/


Venkatesh Macha

Hi Guys, I am Venkatesh Macha. I am a programmer and an Open Source enthusiast, Presently working as a Software Engineer. Apart from that, I love to explore new technologies and things.

You may also like...

Leave a Reply