# Order of Precedence in C

Posted By on September 27, 2016

It is necessary to be careful of the meaning of such expressions as  a + b * c

We may want the effect as either

(a + b) * c

or

a + (b * c)
All operators have a priority, and high priority operators are evaluated before lower priority ones. Operators of the same priority are evaluated from left to right, so that

a - b - c

is evaluated as

( a - b ) - c

as you would expect.

From high priority to low priority the order for all C operators (we have not met all of them yet) is:

( )  [  ]  -> .
!   - * & sizeof cast ++ -
(these are right->left)
* / %
+ -
< <= >= >
== !=
&
|
&&
||
?:        (right->left)
= += -= (right->left)
,   (comma)

Thus

a < 10 && 2 * b < c

is interpreted as
( a < 10 ) && ( ( 2 * b ) < c )

and

a = b = spokes / spokes_per_wheel + spares;

as

a = ( b = ( spokes / spokes_per_wheel ) + spares );

#### Posted by Akash Kurup

Founder and C.E.O, World4Engineers Educationist and Entrepreneur by passion. Orator and blogger by hobby

Website: http://world4engineers.com