Operators and Precedence
Operator | Precedence
|
( )
|
1
|
!
|
2
|
*, /, %
|
3
|
+, -
|
4
|
<, >, <=, >=
|
5
|
==, !=
|
6
|
&&
|
7
|
||
|
8
|
Here, assume these initializations for x and y:
int x = 6;
int y = 3;
Expression | Result
|
(x == 6) && (y == 4)
|
0 (FALSE)
|
(x == 6) || (y == 4)
|
1 (TRUE)
|
(x != 6) || (y != 6)
|
1 (TRUE)
|
(x == y) || (x != y)
|
1 (TRUE)
|
(x == y) && (x != y)
|
0 (FALSE)
|
(x > 3) && (y < 5) && (x != y)
|
1 (TRUE)
|
(x == (y + 3)) && (y == (x - 3))
|
1 (TRUE)
|
!(x == y)
|
1 (TRUE)
|
!(x != y)
|
0 (FALSE)
|
Next page
Previous page
Go to Lesson 7 index.