Variables

Variables can be given a value using an assignment statement:

age=12;
answer='Y';
cost=5.25;

The variable that is getting a value is always on the left.

The statement below will give both num1 and num1 a value of 5.

num1=num2=5;

You can also use cin (console input) to read in a value:

cout<<"Enter age:";
cin>>age;

When we read in from the console we usually use cout to print a prompt before the cin statement.

NEXT: Arithmetic Operations