# Hierarchy of operators

The Priority or Precedence is the order in which the operators are to be performed is called the Hierarchy of operators. The associativity specifies the operator's direction to be evaluated, it may be left to right or right to left.

Priority Operator Description Associativity
(Highest) ( ) Parentheses left-to-right
++ , -- Pre-increment/pre-decrement right-to-left
sizeof Determine size in bytes right-to-left
* , / , % Multiplication, division, modulus left-to-right
+ , - Addition, subtraction left-to-right
< , > , <= , >= Relational less than, less than or equals to,
greater than, greater than or equals to
left-to-right
== , != Relational is equal to/is not equal to left-to-right
++ , -- Post-increment/post-decrement right-to-left
&& Logical AND left-to-right
|| Logical OR left-to-right
?: Ternary conditional right-to-left
(Lowest) = -= += >= <= Assignment right-to-left

Example 1: Program to explain operator precedence.

```#include<stdio.h>
#include<conio.h>

void main()
{
float r;
clrscr();
r = 1.0 + 2.0 * 3.0 / 4.0;
printf("\n%f",r);
r = 1.0 / 2.0 + 3.0;
printf("\n%f",r);
r = (1.0 + 2.0) / 3.0;
printf("\n%f",r);
r = (1.0 + 2.0 / 3.0) + 4.0;
printf("\n%f",r);
getch();
}```
2.500000
3.500000
1.000000
5.666667