0

Trouble understanding While statement excercise

I was completing the While statement practice for C++. I got the correct answer but I canâ€™t figure out why itâ€™s correct. According to the code, shouldnâ€™t this have put out other numbers too? Isnâ€™t it basically taking any number less than 20 and adding 3 to it? So shouldnâ€™t that result in more than just multiples of 3? This is probably super stupid but Iâ€™m brand new at this. https://code.sololearn.com/cn3XGh5mp4F2/?ref=app

12th Jan 2022, 10:38 PM
Jonathan Patterson
+ 2
It's not taking any number because you assigned it to 3 and 3 does not equal more then
12th Jan 2022, 10:44 PM
Ion Kare
0
Oh I see. So instead of it adding 3 to every number under 20, its starting with 3, then adding 3 every time until that number is over 20. Got it. Thanks, mate. I feel dumb but that makes so much more sense now.
12th Jan 2022, 10:48 PM
Jonathan Patterson
0
Yup try changing 20 to 100 and see what happens
12th Jan 2022, 10:49 PM
Ion Kare
0
And change 3 to 1 and see what happens , I suggests re writing the code from scratch till you understand it change the stuff around
12th Jan 2022, 10:50 PM
Ion Kare