Check Prime Number C Program

By | September 19, 2015

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.

5 thoughts on “Check Prime Number C Program

  1. Vishwajeet Kadam

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

  2. Ashok Kandpal

    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.

  3. Vijay Lumar

    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.


Let's Discuss