|
|
|||
The first three lines are the same,
we have discussed already in our first program. Now as we need to use
variables in our program. So we first declare three variables x, y and
z with their data type integer as following. int x; int y; int z;
These three declarations can also
be written on one line. C provides us the comma separator (,). The above
three lines can be written in a single line as below int x, y, z;
As we know that semicolon (;) indicates
the end of the statement. So we can write many statements on a single
line. In this way we can also write the above declarations in the following
form int x; int y; int z;
For good programming practice,
write a single statement on a single line. Now we assign values to variables x and y by using assignment operator. The lines x = 5; and y = 10 assign the values 5 and 10 to the variables x and y, respectively. These statements put the values 5 and 10 to the memory locations labeled as x and y. |
||||
|
Previous |
TOC |
Next |
|