Prime Numbers using Sieve of Eratosthenes: C Program

preview_player
Показать описание

Implement in a c program the following procedure to generate prime numbers from 1 to 100. This procedure is called Sieve of Eratosthenes.

Step 1: Fill an array num[100] with numbers from 1 to 100.

Step 2: Starting with the second entry in the array, set all its multiples to zero.

Step 3: Proceed to the next non-zero element and set all its multiples to zero.

Step 4: Repeat Step 3 till you have set up the multiples of all the non-zero elements to zero.

Step 5: At the conclusion of Step 4, all the non-zero entries left in the array would be prime numbers, so print out these numbers.

C Programming Interview / Viva Q&A List

C Programming: Beginner To Advance To Expert

Join this channel to get access to perks:
Рекомендации по теме
Комментарии
Автор

15:20 in output window 25, 35, 55, 65, 85 and 95 are as prime number 😮🙄

MUKULKUMAR-uclu
Автор

I think this code is wrong because its showing numbers like 55, 275 which are not prime

akashpoudel
Автор

I don't know what the reason for these comments is saying that the code is wrong. I tried it and it was 100% correct. it only prints primes number.

hind-
Автор

it seems your code got wrong results (ex. 25, 55, etc. is not prime numbers), but I wrote the same code and got it correct...

nilschristianhalvorsen
Автор

Pehli baat oh ye code galat hai.. Aur अरे nhi एरे hai...code copy toh dhang se kiya Kro. 😡

blasharma