Relational Operators and Expressions

Here, assume these initializations for x and y:

int x = 6;
int y = 3;


Expression Result
3 < 5 1 (TRUE)
3 == 5 0 (FALSE)
3 != 5 1 (TRUE)
x > y 1 (TRUE)
x == y 0 (FALSE)
x >= y 1 (TRUE)
x != y 1 (TRUE)
x - 3 > y 0 (FALSE)
x - 3 == y 1 (TRUE)
x == 2 * y 1 (TRUE)
2 * x < 4 * y 0 (FALSE)
2 * x <= 4 * y 1 (TRUE)
9 % x == y 1 (TRUE)
(10 - x * 3 >= (y * 4) 0 (FALSE)
((10 - x) * 3 >= (y * 3) 1 (TRUE)
'A' < 'B' (65 < 66) 1 (TRUE)
'A' == 'a' (65 == 97) 0 (FALSE)
'B' < 'a' (66 < 97) 1 (TRUE)
'0' == 0 (48 == 0) 0 (FALSE)

Next page
Previous page
Go to Lesson 7 index.


HTML by Jennifer Keiser.
Sponsored by Inspiration, the diagramming and outlining tool.