Sieve of Eratosthenes Algorithm C Program

By | August 2, 2016

C Program To Implement Sieve of Eratosthenes Algorithm

Learn How To Find Prime Numbers using Sieve of Eratosthenes Algorithm in C Programming Language. This code includes a Sieve Method For Prime Numbers in C Language using Array.

This program uses Sieve Function in C that prints all the Prime Numbers within the given range. The Sieve of Eratosthenes Method is a highly efficient algorithm to find Prime Numbers in a given range where the limit can extend upto 1 Million. The Time Complexity for the Sieve Method to Find Prime Numbers in a given range is total time complexity is O(n * log ( log n)).

Example

Prime Numbers Till 10

2 3 5 7

Must Read: C Program To Find Prime Numbers using Normal Method

C Program For Sieve of Eratosthenes Algorithm using Array

 

Must Read: C Program To Solve Tower of Hanoi Problem without Recursion

 

Output

C Program For Sieve of Eratosthenes Algorithm using Array

If you have any compilation errors or doubts in this Code For Sieve of Eratosthenes Algorithm in C Programming Language, let us know about in the Comment Section below.

2 thoughts on “Sieve of Eratosthenes Algorithm C Program

  1. Vishakha Morani

    Can we not use the simple method to print prime numbers using for loop instead of going for sieve of eratosthenes which is both difficult to pronounce as well as to write?

    Reply
    1. Tushar Soni Post author

      I agree with you. Using For Loop in the Prime Numbers Program is comparatively easier but this sieve method for printing prime number has advantage with Memory and Execution time which is given more priority in realtime systems.

      Reply

Let's Discuss