Introduction
Since C has various types of operators, it also sets precedence rules so that the value of expressions that involve multiple operators should be deterministic.
Program
The precedence of operators is given in Table 3.3.
Operators | Order of evaluation | Remarks |
---|---|---|
[] ( ) -> | Left to right | Array subscript, function call |
− + sizeof( ) ! ++ −− | ||
& * ~ (cast) | Right to left | Unary |
* / % | Left to right | Binary Multiplicative |
+ - | Left to right | Binary Additive |
>> << | Left to right | Shift operators |
< <= > >= | Left to right | Relational operators |
== != | Left to right | Equality operators |
& | Left to right | Bitwise And operator |
^ | Left to right | Bitwise Xor operator |
| | Left to right | Bitwise Or operator |
&& | Left to right | Logical And operator |
|| | Left to right | Logical Or operator |
?: | Left to right | Conditional operator |
= += -= *= /= %= | ||
&= -= |= <<= >>= | Right to left | Assignment |
, | Right to left | Comma |
Point to Remember
The operators are evaluated according to the precedence as shown in Table 3.3.
No comments:
Post a Comment