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];
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.
0
i j screen
0 0 1
1 0 12
1 1 122
2 0 1223
2 1 12233
2 2 122333
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++).