it just doesn't go with the loop anymore
Sure it does. You want to keep a running total, so you want to add into your sum during each cycle. Trace it out by hand to convince yourself (which is a good thing to do with any programming problem).
- sum = 0, you enter 10, sum now = old value of sum + x = 0 + 10 = 10
- next cycle sum = 10, you enter 25, sum now = 10+25 = 35
So it's the loop that keeps adding that new x value on.
Also, please use the code tags to surround any code that you post: