Why is it adding the numbers up incorrectly | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson

Why is it adding the numbers up incorrectly


8th Jan 2019, 10:44 PM
Kian Buchholz
Kian Buchholz - avatar
2 Answers
+ 2
In another way of giving hint to you, you need to move one of your line to the bottom, just before cout.
9th Jan 2019, 4:09 AM
Gordon - avatar
+ 4
In the beginning, you declare five numbers. They are not initialized, so they contain unforeseeable values, just what's sitting at that point in memory right now. You then define total as the sum of all these random numbers as they are now. Then you take user input to put new values into the five number variables. This has no influence on total, which still contains the sum of the former values.
8th Jan 2019, 11:57 PM
HonFu - avatar