main() { int i, j ; i = 5 ; j = 3 ; printf( "sum = %d, product = %d\n", i + j, i * j ) ; }
i = 5 ;
=
) here doesn't mean quite the same thing that it
does in mathematics.
It is the assignment operator.
In many ways it's best to think of it as if it were a left-pointing
arrow.
It takes whatever is on the right and puts it into the variable on
the left.
If that variable had a value previously, then the old value is replaced.
The thing on the right of an assignment may be more than just a number. It may be any expression such as the expressions
i + j i * j
printf
statement.
These expressions are used to do arithmetic.
When the program runs, anywhere an expression appears, that expression
is evaluated and it's value is used as if a number had been put
there.
For example, if instead of the statement j = 3 ;
we had
the statement j = i + 12 ;
, then j
would have the value
17 after that statement was executed.
foo
to the square
of the value of bar
?
(Remember that to square a number, you multiply it by itself.)