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 Associativity
(Highest) ( ) left-to-right
++ , -- right-to-left
* , / , % left-to-right
+ , - left-to-right
< , > , <= , >= left-to-right
== , != left-to-right
&& left-to-right
|| left-to-right
(Lowest) = 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
Ad: unicaf