Built around real course units and objectives!
1) Relational operators allow you to ________ numbers.
A) add
B) multiply
C) compare
D) average
E) None of these - Answer: C
2) After execution of the following code, what will be the value of input_value if the value 0
is entered at the keyboard at run time?
Cin >> input_value;
If (input_value > 5)
Input_value = input_value + 5;
Else if (input_value > 2)
Input_value = input_value + 10;
Else
Input_value = input_value + 15;
A) 15
B) 10
C) 25
D) 0
E) 5 - Answer: A
3) What will be the output of the following code segment after the user enters 0 at the
keyboard?
APPHIA – Crafted with Care and Precision for Academic Excellence.
1
,Int x = -1;
Cout << "Enter a 0 or a 1 from the keyboard: ";
Cin >> x;
If (x)
Cout << "true" << endl;
Else
Cout << "false" << endl;
A) Nothing will be displayed.
B) false
C) x
D) true - Answer: B
APPHIA – Crafted with Care and Precision for Academic Excellence.
2
, A = x >= y;
A) 10
B) 7
C) The string "x >= y"
D) 1
E) 0 - Answer: D
5) If you place a semicolon after the statement:
If (x < y)
A) The code will not compile.
B) The compiler will interpret the semicolon as a null statement.
C) The if statement will always evaluate to false.
D) All of the above
E) None of these - Answer: B
6) When a relational expression is false, it has the value ________.
A) one
B) zero
C) zero, one, or minus one
D) less than zero
E) None of these - Answer: B
7) This is a variable, usually a bool or an int, that signals when a condition exists.
A) relational operator
B) arithmetic operator
APPHIA – Crafted with Care and Precision for Academic Excellence.
3