0
How does the output give 45 and not 10?
Hey everyone, I’m still learning c++ using the book c++ primer, the assignment is to check if the code is valid and what the outputs would be. I’m wondering how sum ends up being 45 instead of 10. https://code.sololearn.com/c2JUjRHM9cpC/?ref=app
1 Resposta
+ 4
You're adding the numbers from 1 to 9 (look at the for loop) to "sum".
1+2+3+...+9 == 45.