
2-14
Computer Programming with C
2.14 INITIALIZING VARIABLES
Variables declared can be assigned or initialized using assignment operator ‘=’. e declaration and
initialization can also be done in the same line.
Syntax:
variable_name = constant;
or
data_type varaible_name= constant;
Example:
x=5; where x is an integer variable.
Example:
int y=4;
Example:
int x,y,z;
e third example as cited above for decla-
ration of variables is also a valid statement.
Illustration of the initialization of a vari-
able is shown in Figures 2.6 and 2.7.
In Figure 2.7, the variable z is assigned a value 1, and z
then assigns its value to y and again y to x. us, initialization ...