7th Mar 2021, 3:45 PM
Ira Sarkar
Ira Sarkar - avatar
11 Answers
+ 5
It's working. your use break keyword. That's why your program stop when it printing 2.
7th Mar 2021, 3:49 PM
Milon
Milon - avatar
+ 5
what the code is doing: it takes numbers in a range , and print all even numbers. but this are not the prime numbers. to see how you can get prime numbers, please use the search bar.
7th Mar 2021, 3:57 PM
Lothar
Lothar - avatar
+ 4
https://code.sololearn.com/ctdW7O1x1MkI/?ref=app
7th Mar 2021, 5:00 PM
Milon
Milon - avatar
+ 3
Ira Sarkar I see it's working
7th Mar 2021, 3:55 PM
Milon
Milon - avatar
+ 3
see
7th Mar 2021, 4:00 PM
Milon
Milon - avatar
+ 2
Milon If you want to get the prime numbers, try to add an another for loop inside. Check if even, if it is then it is automatically not a prime number. If not, iterate numbers from 3 to i then check if i is divisible by atleast one of those numbers. If it is, then it is not prime. [ Syntax ] : for (int i=3; i<300; i++) { if (i%2 == 0) { continue } for (int j=3; j<i; j++) { if (i % j == 0) continue } printf(...); } 7 // the rest is up to you. btw i didnt include 2 inside as it is already a prime number (printed beforehand). If you need more help, feel free to ask. Thanks.
7th Mar 2021, 4:11 PM
noteve
noteve - avatar
0
Milon its not working.
7th Mar 2021, 3:53 PM
Ira Sarkar
Ira Sarkar - avatar
0
Milon nope, it's not printing prime no.
7th Mar 2021, 3:56 PM
Ira Sarkar
Ira Sarkar - avatar
0
Lothar yes,but I want to print prime nos
7th Mar 2021, 3:57 PM
Ira Sarkar
Ira Sarkar - avatar
7th Mar 2021, 4:57 PM
arturop200
arturop200 - avatar