Assigning Values to Variables

This lesson teaches us about variables, the assignment operator and how the assignment operator can be used to assign values to variables.

Assignment and order of evaluation #

The first two difficulties that most people face when learning to program involve the assignment operation and the order of evaluation in an expression.

The assignment operation #

You will see lines similar to the following in almost every program in almost every programming language:

a = 10;

The meaning of this line is “make a hold the value 10.” Similarly, the following line means “make b hold the value 20”:

b = 20;

Based on that information, what can be said about the following line?

a = b;

Unfortunately, ...