Why its not printing?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Why its not printing??

I'm trying to learn continue and break statements, so i made an example on continue statement. My code should print the value of variable 'number'. But its not printing, idk what is wrong with my code. Someone clear my doubt. Here's my code: https://code.sololearn.com/ccFw0YPK1wkz

22nd Sep 2020, 3:44 PM
Jayakrishna
3 Answers
+ 7
You likley know this, but there is a saying about 'assuming'. So to be clear, >= means greater than or equal to and <= means less than or equal to. So on the first iteration of the loop your were testing if 1 is grater than or equal to 10 which it is not so the loop terminated on the first pass.
22nd Sep 2020, 4:05 PM
Paul K Sadler
Paul K Sadler - avatar
+ 5
It's correct that it doesn't print anything. The reason for that is because the program will not iterate over the for loop. Your for loop is: `for (int number=1;number>=10;number++)`. This means before starting each for-loop iteration, the condition `number >= 10` is checked (and the iteration is done only if the condition evaluates as true). I suppose you were looking for `number <= 10` or something similar.
22nd Sep 2020, 3:56 PM
Mihai Iacov
Mihai Iacov - avatar
+ 3
~ swim ~ Michael XD Paul K Sadler lol, Now I got it. Thanks everyone for helping me. Happy to hear your replies. Thank you 😊
22nd Sep 2020, 6:54 PM
Jayakrishna