Skip to content
← Back to Community
what is the code for getting output of first 100 prime numbers in c ?
Profile icon
hridaym

first 100
this code is for 1-100 but then i tried to make changes but it is still the same

Voters
Profile icon
DenniseArenas
Profile icon
hridaym
Comments
hotnewtop
Profile icon
Highwayman

N is the number you are checking for primality, so instead make a second counter (primes_found) and increase it by one every time n is a prime number. Then check for whether primes_found reaches 100 instead of n.