0
Working with Array.cpp array calculation.Help please.Why this code output wrong??
4 Réponses
+ 5
What exactly?
If output, then this is explanation of output:
1) adding 1 to 0, printing "1";
2) adding 2 to 1, printing "3";
3) adding 3 to 3, printing "6";
4) adding 4 to 6, printing "10";
5) adding 5 to 10, printing "15";
6) adding 6 to 15, printing "21";
7) adding 7 to 21, printing "28";
8) adding 8 to 28, printing "36".
Final output: "1361015212836" ("1" + "3" + "6" + "10" + "15" + "21" + "28" + "36").
Note: try placing `cout<<x;` outside the "for" curly brackets to print only the final value (36).
+ 8
Shubham Dhyani , as the output expression is placed inside the for loop, it will be executed in each iteration.
BTW, your description of ".. why this code is not working? ..." does not really help, because this can mean anything.
0
Thanks to give time to solve my problem
0
But why this happens if inside curley bracket