Chapter 4 Review

¡Supera tus tareas y exámenes ahora con Quizwiz!

none

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. all only the last one any one none at least two

flag

A(n) ________ is a variable, usually a bool, that signals when a condition exists. logical variable condition variable flag named constant identifier

&&

The C++ ________ operator represents logical AND. ++ .AND. && & ||

if/else

The ________ statement executes one block of statements if a test condition is true, and another block if the condition is false. trailing else if/else if/else if if switch

if

The ________ statement executes one statement, or block of statements, if a condition is true and skips it, doing nothing, if the condition is false. if/else if if/else if switch if/endif

trailing else

The default section of a switch statement performs a similar task as the ________ portion of an if/else if statement. break conditional test body else if trailing else

Assign 1 to answer.

What will the following statement do if x equals 17 and answer = 20? Assign 0 to answer. Assign 0 to x. Assign 17 to answer. Assign 1 to x. Assign 1 to answer.

bool

A flag is a variable, usually of data type ________, that signals whether or not some condition exists. bool logical char string int

None of these because in each case one or more characters in the strings have different ASCII codes.

If s1 and s2 are string objects, s1 == s2 is true when s1 = "lion" and s2 = "lioness". s1 = "dog" and s2 = "DOG". s1 = "cat" and s2 = "cat ". None of these because in each case one or more characters in the strings have different ASCII codes. None of these because string objects cannot be compared with relational operators.

0

In C++ when a relational expression is false, it has the value 1. 0. -1. "0". of any negative number.

compare

Relational operators allow you to ________ numbers. multiply average compare add verify

if/else if

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. if/then if/not if if/else if if/else if/endif

if

The ________ statement causes other program statements to execute only under certain conditions. cout logical cin relational if

False

True/False: The scope of a variable is the program it is defined in. True False

true

What will the following expression evaluate to? 0 -1 6 true false

input validation.

When a program lets the user know that an invalid menu choice has been made, this is an example of output validation. being user unfriendly. input validation. menu reselection. invalidation.

enum student { Bill, Tom, Mary };

Which of the following correctly declares an enumerated data type named student? enum student { Bill, Tom, Mary }; enum student { "Bill", "Tom", "Mary" }; int Bill = 1, Tom = 2, Mary = 3;enum student { 1, 2, 3 }; Any of these 3 methods will work. None of these 3 methods will work.

||

The ________ operator is known as the logical OR operator. && & ! // ||

==

The ________ operator is used in C++ to test for equality. == || = <> &&

!

The ________ operator takes an operand and reverses its truth or falsehood. || != relational && !

nested if

When an if statement is placed within the conditionally-executed code of another if statement, this is known as a(n) double if conditional if nested if complex if overloaded if


Conjuntos de estudio relacionados

Forms of Business Organizations (Sole Proprietorships, Partnerships, Corporations) 2B

View Set

Essential Cosmic Perspective : Ch. 3 HW & Quiz

View Set