List and explain the precedence of Arithmetic, Logical and Relational operators in ‘C’. 10m Dec2007

By | June 9, 2015

List and explain the precedence of Arithmetic, Logical and Relational operators in ‘C’. 10m Dec2007

C uses a certain hierarchy to solve such kind of mixed expressions. The hierarchy and associatively of the operators discussed so far is summarized in Table. The operators written in the same line have the same priority. The higher precedence operators are written first

ARITHMETIC OPERATORS

+ Addition
Subtraction
* Multiplication
/ Division
% Modular Division

Arithmetic operators are used for making mathematical expression and evaluating results in any kind of formulas by using Brackets wherever needed.

RELATIONAL OPERATORS

Operator Check Condition Meaning
== X==Y X is equal to Y
!= X!=Y X is not equal to Y
< X<Y X is less than Y
<= X<=Y X is less than or equal to Y
> X>Y X is greater than Y
>= X>=Y X is greater than or equal to Y

Relational operators are used to check any condition by comparing the values of variables used inside a program. The result of any comparison (condition) will give you true or false only.

LOGICAL OPERATORS

Operator Meaning
&& Logical AND
|| Logical OR
! Logical NOT

Logical operators (AND and OR) combine two conditions and logical NOT is used to negate the condition i.e. if the condition is true, NOT negates it to false and vice versa.