Assigning Values to Variables
A Value can be assigned to variables using the assignment operator (=): -
var_name=expression;
An expression can be a single constant or a combination of operators, variables and constants. The statements:
p1=3250.00; (the expression is a single numeric constant)
p2=4570.00;
p3= p1+p2; (the expression is a sum of price1 and price2)
are known as assignment statements. Each statement must have a colon at the end. A statement implies in which the value of the variable on the left of = is set to the value of the expression on the right. Thus,
count=count+1;
implies in which the 'new value' of count (left side) has been set to the 'old value' of count plus 1 (right side).
The variables can be assigned a value at the time of the declaration itself. This is known as initialization. The common format is: -
Data-type var_name=constant;