Chapter 4 c++

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

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

input validation

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

The ________ operator is known as the logical OR operator

||

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

==

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.

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

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

False

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

False

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

False

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

False

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"

False

All of the relational operators are binary

True

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

True

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

True

Characters and string objects can be compared with any of the relational operators.

True

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

True

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

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

True

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

The statement pass = (score >= 7) ? true : false; does exactly the same thing as the if/else statement below: if (score >= 7) pass = true; else pass = false;

True

A flag is a variable, usually of data type ________, that signals when a 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

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

flag

The ________ statement can cause other program statements to execute only under certain conditions

if

The _________ statement executes one statement, or block of statement, if 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

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

nested if

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

true

The C++ ________ operator represents logical AND

&&

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

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

0

What will the following statement assign to variable answer if x equals 17? answer = x > 100 ? 0 : 1;

1

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 one or more characters in the strings have different ASCII codes

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

enum student { Bill, Tom, Mary };

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

!


संबंधित स्टडी सेट्स

Micro Final- Ch. 10 externalities, Chapter 10 - Externalities ME, Chapter 10: Externalities, chapter 13: the cost of production, Chapter 13: Costs of Production, Microeconomics Final Exam

View Set

Tema 4 Variables aleatorias continuas

View Set

ch quizzes and pratice exam for final

View Set

Chapter 1: Introduction to Biology

View Set

Insurance chapter 3( legal concepts)

View Set