Question 4-1. What is the difference between the =
and ==
operators?
Question 4-2. Suppose I have four different variables, a, b, c
, and d
. What’s the shortest way to assign them all the value 36?
Question 4-3. What’s the difference between dividing two int
s and dividing two double
s?
Question 4-4. What is the purpose of the %
operator?
Question 4-5. What is the output of these operations?
4 * 8
(4 + 8) / (4 – 2)
4 + 8 / 4 – 2
Question 4-6. Let myInt
= 25 to start. What is the value of myInt
at each stage of the following code?
myInt += 5; myInt -= 15; myInt *= 4; myInt /= 3;
Question 4-7. Describe the difference between the prefix and postfix operators.
Question 4-8. Let x
= 25 and y
= 5. What do these expressions evaluate to?
(x >= y) (x >= y * 5) (x == y) (x = y)
Question 4-9. Let x
= 25 and y
= 5. What do these expressions evaluate to?
(x >= y) && (y <= x) !(x > y) !(x < y) && (x > y) ((x > y) || !(x < y)) && (x > y) ((x > y) && ((y < x) || (x > y))) && (x == y)
Question 4-10. Arrange these operators in order of precedence:
% != ?: && ++