+ 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
4 Antworten
+ 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.
+ 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.
+ 3
~ swim ~ Michael XD Paul K Sadler lol, Now I got it. Thanks everyone for helping me. Happy to hear your replies. Thank you 😊