Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
A game score starts at . The player gets points, then points, and then the score is doubled. Use one variable called score. What is the final score?
The right side uses the old value. The result is stored back in the same name.
Have you tried it?
Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, go through the solution one step at a time, and check each step against your own.
Plan. Change the same variable step by step.
score = 0score = score + 10 makes it 10.score = score + 5 makes it 15.score = score * 2 makes it 30.Check. .
Answer: 30.
Log in to join the discussion.
Loading…