An expression is a combination of variables, constants and
operators arranged according to syntax of the language. Some examples of
expressions are:
c = (m
+ n) * (a - b);
temp =
(a + b + c) / (d - c);
Expression
is evaluated by using assignment statement.
Such a
statement is of the form
variable
= Expression;
The expression on the L.H.S is evaluated first, then the
value is assigned to the variable. But all the relevant variables must be
assigned the values before the evaluation of the expression.
Evaluation of
Expression
By using assignment statement we can evaluate an
expression.
variable=expression;
The expression is evaluated first and then a value is
assigned to the variable on the left hand side.
e.g.: temp = ( (
f * cos ( x ) / sin ( y ) ) + ( g * sin ( x ) / cos ( y ) ) )
All relevant variables must be assigned values before the
evaluation of the expression.
No comments:
Post a Comment