Turn Desktop View Off
You are here:   HomeC Programming (Theory)Control Structures in CWrite a C program to find if the given number is prime or not.
by Dinesh Thakur Category: Control Structures

An integer number is prime if it is not evenly divisible by any number other than 1 and the number itself. Thus, to test whether a given number num is prime or not, we need to divide it by integers from 2 to num- 1and test whether the remainder is zero or not.

void main()
int p,n;
printf("\n Specify a number:");
printf("\n It is not a prime number");
printf("This number is divisible by %d",p);
printf("\n It is a prime number");

Subscribe To Free Daily Newsletter!

Get Free News Updates Delivered Directly To Your Inbox
About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to contact us.

What's New and Popular

Popular Article