Arrays and strings · Exercise 1 of 100

Sum of Two Numbers

To add two integers on a number line, start at the first number. A positive second number moves you right, and a negative one moves you left. The number you land on is the sum.

Try it yourself

The temperature starts at -4 degrees and rises by 11 degrees. What is the new temperature in degrees?

One-step hint

Mark −4 on a number line. Spend enough of the 11-degree rise to reach zero, then count the degrees left to move.

Worked solution
  1. Start at -4 and use 4 of the 11 steps to reach zero.
  2. The remaining 7 steps take you right from zero to 7.
DSA compiler