21. For what exact range of values of variable x does the following code segment
display the letter `C'?
(a) 0 < x < 100
(b) x <= 0
(c) 100 <= x <= 200
(d) x > 200
(e) 100 < x <= 200
A question from a sample midterm I have, this question is confusing me. The code is attached for this one.
So if x < 200 it will print A, but if its below 100 it will print B, so it has to be between 100 and 200 so the answer is e to print C?
Edit: Another question
22. The e®ect of the following program segment can best be described as .
if (x > y)
z = x;
if (x == y)
z = 0;
if (x < y)
z = y;
(a) The smaller of x and y is stored in z.
(b) The larger of x and y is stored in z unless x and y are equal, in which case
z is assigned zero.
(c) The larger of x and y is stored in z.
(d) The larger of x and y is stored in z unless x and y are not equal, in which
case z is assigned zero.
(e) none of the above
if x is greater than y, then x is stored in z, so the answer is c?
Thanks for any help.
display the letter `C'?
(a) 0 < x < 100
(b) x <= 0
(c) 100 <= x <= 200
(d) x > 200
(e) 100 < x <= 200
A question from a sample midterm I have, this question is confusing me. The code is attached for this one.
So if x < 200 it will print A, but if its below 100 it will print B, so it has to be between 100 and 200 so the answer is e to print C?
Edit: Another question
22. The e®ect of the following program segment can best be described as .
if (x > y)
z = x;
if (x == y)
z = 0;
if (x < y)
z = y;
(a) The smaller of x and y is stored in z.
(b) The larger of x and y is stored in z unless x and y are equal, in which case
z is assigned zero.
(c) The larger of x and y is stored in z.
(d) The larger of x and y is stored in z unless x and y are not equal, in which
case z is assigned zero.
(e) none of the above
if x is greater than y, then x is stored in z, so the answer is c?
Thanks for any help.