Title: Assignment Statement
Course: CPS 120: Introduction to Computer Science ~ Master (Aug/2015) OLD > Section: Learning Units

- Places the value of the expression on the right into the variable on the left.
- Usually the data type of the expression must match the data type of the variable.

For example, you cannot place a string expression into an integer, but you can place a real number into an integer (it will get truncated).

Assignment Statement: Variables with Examples

variable = expression;
for example, grade = grade + 10;

variable = value;
for example, age = 34;

variable = another variable;
for example, test1 = test2;

Assignment Statement: Additional Examples

Index = 44;

Salary = 35000.25;

FirstName = "Alvin";

CharacterCode = 'M';

Flag = true;