C++ Chapter 4 Test

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

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

!

The C++ _____ operator represents logical AND.

&&

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

0

The ____ operator is used in C++ to test for equality.

==

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

Assign 1 to answer

The following C++ test checks if the variable child is in the 3-12. if (child >= 3 && <= 12)

False

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

False

True/False: The following C++ test checks if the variable child is in the range 3-12. if (child >= 3 || child <= 12)

False

True/False: The following statement s will print Hello. x = 5; if(x < 5) cout << "Hello";

False

True/False: The three logical operators, AND, OR, and NOT, all have the same precedence.

False

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

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

True/False: A pair of characters or a pair of string objects can be compared with any of the relational operators.

True

True/False: All of the relational operators are binary.

True

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

True

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

True

True/False: If the sub-expression on the left side of an I operator is true, the expression on the right side will not be checked.

True

True/False: In C++ an expression that evaluates to 5, -5, or for that matter anything other than 0, is considered true by an if statement.

True

True/False: Relational expressions and logical expressions are both Boolean, which means they evaluate to true or false.

True

True/False: Relational operators connect two or more relational expressions into one, or reverse the logic of an expression.

True

True/False: The rule for matching an else with an if, is that an else goes with the last if statement before it that doesn't have its own else.

True

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

True

A flag is a variable, usually of data tуре ______, that signals whether or not some condition exists.

bool

If a switch statement has no _____ statements, the program "falls through" all of the statements below the one with the matching case expression.

break

Relational operators allow you to _____ numbers.

compare

Which of the following correctly declares an enumerated data type named student?

enum student ( Bill, Tom, Mary );

A(n) ____ is a variable, usually a bool, that signals when a condition exists.

flag

The _____ statement causes other program statements to execute only under certain conditions.

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

Two different variables in the same program may have the same name

if they have different scope

The _____ statement executes one block of statements if a test condition is true. and another block if the condition is false.

if/else

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.

if/else if

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

input validation

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

nested if

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.

none

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

relational

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

trailing else

True/False: The following two sections of code do the same thing. pass = (score ›= 7) ? true : false; if (score >= 7) pass = true; else pass = false;

true

True/False: What is the value of boolAns? x = 0; boolAns = (2 * 3 == 6 || 10.2 / ×);

true

Which of the following are logical operators. Check all that apply.

|| ! &&


Set pelajaran terkait

STRATEGIC MANAGEMENT Chapter 3, The External Assessment

View Set

NEC Chapter 4: Equipment for General Use

View Set

Leadership & Management Module 19

View Set