Mathematics I / Variables, Types, and Expressions
Practice question · Multiple choice

In mathematics x = x + 1 is a contradiction with no solution. In most programming languages it is a routine instruction. Why do the same symbols mean such different things?

Hints
  1. Ask what the machine actually does, step by step, when it executes the line.
  2. Which x is evaluated first, and which one is written to?
Show the answer

C. Because the programming version is an instruction, not an assertion.

Why

The line is a command with an order of operations: evaluate the right side using the current x, then store the result. Nothing is asserted, so nothing can be contradicted, and the two x's are different moments the notation conceals. A mathematical variable stands for one fixed value throughout; a program variable is a container whose contents change over time.

Read the lesson: Variables, Types, and Expressions →

Practise Variables, Types, and Expressions

The app has 4 more questions on this lesson, and keeps your place in the course. Mathematics I is free to start.

More questions on Variables, Types, and Expressions