0

How's the output is 122333

char a[] ="123"; int i.j; for(i=0;i<3;i++) { for(j=0;j<=i;j++) { cout<<a[i];

9th Jan 2020, 1:38 PM
Ariz imam
Ariz imam - avatar
3 Answers
+ 4
Take a pen and paper and go step by step to understand the result. Or kindly revise it again just like ~ swim ~ mentioned because you shouldn't struggle with such easy looping when you have already reached OOP in your course.
9th Jan 2020, 2:12 PM
Avinesh
Avinesh - avatar
0
i j screen 0 0 1 1 0 12 1 1 122 2 0 1223 2 1 12233 2 2 122333
10th Jan 2020, 7:35 PM
Kairat Soltanalinov
Kairat Soltanalinov - avatar
0
First, the loops need that curly brace at the end. Secondly, the answer is 122333 because every time the loop runs the loop inside the first loop runs i + 1 times. You can check the code in online debugging websites, like pythontutor.com (that also has debugging for c++).
10th Jan 2020, 10:57 PM
CeePlusPlus
CeePlusPlus - avatar