Filters
Question type

Study Flashcards

The following statements will not print anything. x = 5; if (x < 5) cout << "Hello "; cout << "world \n";

A) True
B) False

Correct Answer

verifed

verified

What will the following statement do if x equals 17 and answer = 20? Answer = x > 100 ? 0 : 1;


A) Assign 0 to answer.
B) Assign 0 to x.
C) Assign 1 to answer.
D) Assign 1 to x.
E) Assign 17 to answer.

F) A) and D)
G) C) and D)

Correct Answer

verifed

verified

The ________ operator takes an operand and reverses its truth or falsehood.


A) relational
B) &&
C) ||
D) !
E) !=

F) All of the above
G) B) and C)

Correct Answer

verifed

verified

Relational operators allow you to ________ numbers.


A) add
B) multiply
C) compare
D) average
E) verify

F) A) and D)
G) A) and C)

Correct Answer

verifed

verified

What will the following expression evaluate to? !( 6 > 7 || 3 == 4)


A) 0
B) -1
C) 6
D) True
E) false

F) C) and D)
G) B) and E)

Correct Answer

verifed

verified

An expression in a C++ if statement that evaluates to 5, -5, or for that matter anything other than 0, is considered True.

A) True
B) False

Correct Answer

verifed

verified

Assuming moreData is a Boolean variable, the following two tests are logically equivalent. if (moreData == True) if (moreData)

A) True
B) False

Correct Answer

verifed

verified

A switch statement branches to a particular block of code depending on the value of a numeric (i.e. integer or floating-point) variable or constant.

A) True
B) False

Correct Answer

verifed

verified

A trailing else placed at the end of an if/else if statement provides a default action when ________ of the if conditions is/are True.


A) none
B) any one
C) only the last one
D) at least two
E) all

F) C) and D)
G) All of the above

Correct Answer

verifed

verified

The expression x < y is called a(n) ________ expression.


A) arithmetic
B) logical
C) relational
D) comparison
E) binary

F) C) and E)
G) B) and D)

Correct Answer

verifed

verified

To check if a variable has a particular value, use the = relational operator, as in the statement if (s = 3) cout << "S has the value 3";

A) True
B) False

Correct Answer

verifed

verified

The ________ statement executes one statement, or block of statements, if a condition is True and skips it, doing nothing, if the condition is false.


A) if
B) if/else
C) if/else if
D) switch
E) if/endif

F) B) and E)
G) A) and B)

Correct Answer

verifed

verified

The ________ statement acts like a chain of if statements. Each performs its test, one after the other, until one of them is found to be True or until the construct is exited without any test ever evaluating to True.


A) if/then
B) if/else
C) if/else if
D) if/not if
E) if/endif

F) A) and C)
G) B) and D)

Correct Answer

verifed

verified

In C++ when a relational expression is false, it has the value


A) 1.
B) 0.
C) -1.
D) "0".
E) of any negative number.

F) A) and B)
G) All of the above

Correct Answer

verifed

verified

The default section of a switch statement performs a similar task as the ________ portion of an if/else if statement.


A) conditional test
B) break
C) trailing else
D) else if
E) body

F) A) and E)
G) A) and D)

Correct Answer

verifed

verified

Assuming goodData is a Boolean variable, the following two tests are logically equivalent. if (goodData == false) if (!goodData)

A) True
B) False

Correct Answer

verifed

verified

All of the relational operators are binary.

A) True
B) False

Correct Answer

verifed

verified

If s1 and s2 are string objects, s1 == s2 is True when


A) s1 = "lion" and s2 = "lioness".
B) s1 = "dog" and s2 = "DOG".
C) s1 = "cat" and s2 = "cat ".
D) None of these because in each case one or more characters in the strings have different ASCII codes.
E) None of these because string objects cannot be compared with relational operators.

F) None of the above
G) All of the above

Correct Answer

verifed

verified

If the sub-expression on the left side of an && operator is True, the expression on the right side will not be checked.

A) True
B) False

Correct Answer

verifed

verified

When a program lets the user know that an invalid menu choice has been made, this is an example of


A) input validation.
B) output validation.
C) menu reselection.
D) invalidation.
E) being user unfriendly.

F) B) and C)
G) A) and B)

Correct Answer

verifed

verified

Showing 21 - 40 of 40

Related Exams

Show Answer