Data Type of An Expression
The data type of an expression depends upon the types of its operands. For example, an arithmetic expression is given below.
a * b
Operators Precedence
The order in which arithmetic operations are perform to evaluate an expression is called the operator precedence. It is also known as hierarchy of operators. The arithmetic expressions is evaluated in the same manner as that of algebraic expression. When an arithmetic expression is evaluated, the computer performs only one operation at a time.
An arithmetic expression without parenthesis is evaluated as follows:
- All multiplications and divisions are evaluated first from left to right.
- All additions and subtractions are then performed from left to right.
i) 2*5 is computed first and returns value 10.
ii) 6 + 10 is computed and returns value 16.
No comments:
Post a Comment
Thanks For Visiting Here...!! I will Reply you as soon as possible.