Sunday, January 25, 2009

Hierarchy of operations

In an arithmetic operation, while execution of two or more operators , we some time have some problem as to how does it get executed. Lets take an example to understand the thing more properly, we consider an arithmetic expression:
5*m – 7*n

Now sometimes we face problem regarding the execution of the expression, does it corresponds to (5m)-(7n) or 5(m-7n) ? Thus to solve this kind of problems we have to understand the Hierarchy of operations. The priority or the precedence in which the operations in an arithmetic expression are performed is called the hierarchy of operation.

The hierarchy of commonly used operators is shown in the table below:

Priority Operators Description
First * / % Multiplication, Division, Modular Division
Second + - Addition, Subtraction
Third = Assignment

No comments:

Post a Comment

Please give your valuable comments or queries if you fell its helpful or if you like the contents of the site. Thanks...