i wrote a basic program for my C++ class that includes SUMs and while loops.
its fairly self explanatory, but i am not getting the correct SUMs for my outputs.
apparently, i am missing something extremely important somewhere here.
can someone take a look and give me a few hints as to why my outputs are coming out the way they are...
thank you.
note: why i have so much variables here is because my teacher wants it that way. i would use an array to make the program look neater, but i was instructed to keep it as simple and as basic as possible. =)
In the bit above your while loop all you're doing is adding together uninitialized variables, hence why you're receiving garbage values. You need to move your totals inside your loop after you have read in the values of numX, numY and numZ. You might want to check your output once the sums have been performed too. If the values of sum1, sum2 and sum3 are 3, 4 and 5 respectively, you will get this output from line 37:
345 = 12
Which I'm guessing is not what you want.
Remember that your code will run from top to bottom, and if things aren't in the right order, you won't get the results you want.