Check Prime Number C Program

C Program To Check Prime Number

Learn How To Check Prime Number in C Programming Language. It is important that we should know How A For Loop Works before getting further with this C Program.

What is a Prime Number?

A Prime Number is a Natural Number Greater than 1 and it should have No Positive Divisors other than 1 and the Number itself. A Natural Number greater than 1 but not a Prime Integer is known as a Composite Number.


2, 3, 5, 7 ,11

These numbers are evenly divided by 1 and the number itself.

Must Read: C Program To Find Prime Numbers using Sieve of Eratosthenes Algorithm

Method 1: C Program To Find Prime Number using For Loop

Method 2: C Program To Check Prime Numbers using While Loop

Also Read: Convert Number To Words in C Programming


C Program To Check Prime Number using For and While Loop

Alternatively, you can also use this Condition  in the Loop.


The above Condition count<=num/2 is an efficient Algorithm to Check Prime Integers and helps to reduce the Number of Comparisons and thereby efficient time complexity.

Method 3: Sieve Method To Find Prime Numbers in C Programming

If you have any compilation errors or doubts in this C Program To Check Prime Numbers, let us know about in the Comment Section below.

Tushar Soni

I am Tushar Soni, Co - Founder of CodingAlpha. I am a computer science student from India and passionate about Web Development and Programming. Connect with me on Facebook | LinkedIn | Google Plus

5 thoughts on “Check Prime Number C Program

  • August 3, 2016 at 1:54 pm

    What is this sieve method for finding prime numbers about? Its quite confusing.

  • September 11, 2016 at 2:23 pm

    This is really good. So many methods to print Prime Numbers. Thanks.

  • September 11, 2016 at 2:32 pm

    I used to get lost in the For loop conditions. This is by far the best code for Prime Number checking that I have come across so far.

  • September 13, 2016 at 10:23 pm

    Amazing. I had never heard that there something called as Sieve method to find Prime Numbers in C programming. Thanks. You introduce so mamy concepts that no has even heard of.

  • April 7, 2017 at 2:25 pm

    while(count <= num – 1)


Join The Discussion