0
Explain the output of the given code taken from C++ challenges
for(int i = 0;i<=2;i++) { for(int j = 0; j <=i; j++){ cout << "*";} cout << "_"; }; This code give the output *_**_ Anyone Explain how this answer come }
2 Respuestas
+ 4
Saad Mughal Actually your output is wrong and your code has many mistakes
First iteration
i=0 j=0 prints *_
Second iteration
i=1 j=0 prints *
i=1 j=1 prints *_
Third iteration
i=2 j=0 prints *
i=2 j=1 prints *
i=2 j=2 prints *_
Overall output
*_**_***_
+ 1
Yeah i corrected my code but the code and answer is same as the challenge question but if it is incorrect I understand the way you explained there Thanks