Its output is 35. I want to know how it happened. | Sololearn: Learn to code for FREE!

+1

Its output is 35. I want to know how it happened.

for(int i = 3; i <= 5; i++) { cout << i; i++; }

8/31/2020 9:00:24 PM

Bayzid

3 Answers

New Answer

+3

Man what were you doing when you completed the C++ course? i = 3, i <= 5? yes output i // 3 is printed then i is incremented i becones 4, then i is again incremented as part of for loop increment expression so i becomes 5 next iteration i = 5, i <= 5 ? yes print i, // 5 is printed so output now is 35 then i is incremented first in loop body then in for loop increment expression so i is now 7 next iteration i = 7, i <= 5 ? false, loop exits you have 35 as output Revise your C++ course again, don't be lazy.

+2

It is not 35 but 3 and 5 written without space

+2

Thank you