C++ Chpt_04 GRADE A QUESTION WITH
ANSWERS
1. An expression using the greater-than, less-than, greater-than-or-equal-to, less-than-
or equal-to, equal, or not-equal operator is called a(n) - (correct answer)'Relational
expression.
2. The value of a relational expression is 0 if the expression is - (correct
answer)expression is 'False'.
'True' or 1 if the
3. The if statement regards an expression with the value 0 as 'False' and an expression
with a non zero value as 'True'. - (correct answer)False True
4. For an if statement to conditionally execute a group of statements, the statements
must be enclosed in a set of . - (correct answer)'Braces'
5. In an if/else statement, the if part executes its statement(s) if the expression is 'True',
and the else part executes its statement(s) if the expression is 'False'. - (correct
answer)True False
6. The trailing else in an if/else if statement has a similar purpose as the ' ' section of a
switch statement. - (correct answer)Default
7. If the sub-expression on the left of the && logical operator is 'False', the right sub-
expression is not checked. - (correct answer)False
8. If the sub-expression on the left of the || logical operator is 'True', the right sub-
expression is not checked. - (correct answer)True
9. The '!' logical operator has higher precedence than the other logical
, operators. - (correct answer)!
10. Logical operators have ' ' precedence than relational operators. - (correct
answer)Lower
11. The '&&' logical operator works best when testing a number to determine if it is
within a range. - (correct answer)&&
12. The '||' logical operator works best when testing a number to determine if it is
outside a range. - (correct answer)||
13. A variable with " "(or local)' scope is only visible when the program is executing in
the block containing the variable's definition. - (correct answer)Block
14. The expression that follows the switch statement must have a(n) 'Integer' value. -
(correct answer)Integer
15. A program will "fall through" to the following case section if it is missing the 'Break'
statement. - (correct answer)Break
16. What value will be stored in the variable t after each of the following statements
executes? - (correct answer)A) t = (12 > 1); '1'
B) t = (2 < 0); '0'
C) t = (5 == (3 * 2)); '0'
D) t = (5 == 5); '1'
17. Write an if statement that assigns 100 to x when y is equal to 0. - (correct answer)if
(y==0)
x = 100;
ANSWERS
1. An expression using the greater-than, less-than, greater-than-or-equal-to, less-than-
or equal-to, equal, or not-equal operator is called a(n) - (correct answer)'Relational
expression.
2. The value of a relational expression is 0 if the expression is - (correct
answer)expression is 'False'.
'True' or 1 if the
3. The if statement regards an expression with the value 0 as 'False' and an expression
with a non zero value as 'True'. - (correct answer)False True
4. For an if statement to conditionally execute a group of statements, the statements
must be enclosed in a set of . - (correct answer)'Braces'
5. In an if/else statement, the if part executes its statement(s) if the expression is 'True',
and the else part executes its statement(s) if the expression is 'False'. - (correct
answer)True False
6. The trailing else in an if/else if statement has a similar purpose as the ' ' section of a
switch statement. - (correct answer)Default
7. If the sub-expression on the left of the && logical operator is 'False', the right sub-
expression is not checked. - (correct answer)False
8. If the sub-expression on the left of the || logical operator is 'True', the right sub-
expression is not checked. - (correct answer)True
9. The '!' logical operator has higher precedence than the other logical
, operators. - (correct answer)!
10. Logical operators have ' ' precedence than relational operators. - (correct
answer)Lower
11. The '&&' logical operator works best when testing a number to determine if it is
within a range. - (correct answer)&&
12. The '||' logical operator works best when testing a number to determine if it is
outside a range. - (correct answer)||
13. A variable with " "(or local)' scope is only visible when the program is executing in
the block containing the variable's definition. - (correct answer)Block
14. The expression that follows the switch statement must have a(n) 'Integer' value. -
(correct answer)Integer
15. A program will "fall through" to the following case section if it is missing the 'Break'
statement. - (correct answer)Break
16. What value will be stored in the variable t after each of the following statements
executes? - (correct answer)A) t = (12 > 1); '1'
B) t = (2 < 0); '0'
C) t = (5 == (3 * 2)); '0'
D) t = (5 == 5); '1'
17. Write an if statement that assigns 100 to x when y is equal to 0. - (correct answer)if
(y==0)
x = 100;