# need to understand code

Printable View

• 02-17-2011, 03:38 PM
Masken2
need to understand code
Iterating over the numbers 1 .. 10 and write in each an iteration (cycles in the loop) the sum of the current number and all the previous figures. Eg fourth iteration is the number 1 +2 +3 +4 = 10. For the first four iterations will be printed in the console 1, 3, 6, 10. Tip: for an extra variable that you use to store the value from the previous iterations.

What i have got is that i know tthat i have to make a program that adds the preveius numbers with the next like 1+2 = 3 ant then 1+2+3=6 and so on but i dont know were to put it so that the next number apperars in the next line
• 02-17-2011, 03:44 PM
KevinWorkman
Sorry, but you can't just keep posting your homework questions here without showing any real effort. What have you tried? What worked, what didn't work? How didn't it work? Be specific.

Throw together an SSCCE that demonstrates where you're stuck, and we can go from there.
• 02-17-2011, 05:21 PM
Debugger
Read up on loops, for loop, while, do while, and decide which is best to solve your problem