C++ CHAPTER 4

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

When a relational expression is false, it has the value

0

What is assigned to the variable result given the statement below with the following assumptions: x = 10, y = 7, and x, result, and y are all int variables. result = x >= y;

1

After the following code executes, what is the value of my_value if the user enters 0? cin >> my_value; if (my_value > 5) my_value = my_value + 5; else if (my_value > 2) my_value = my_value + 10; else my_value = my_value + 15;

15

The __________ is an equality (or comparison) operator.

==

Relational operators allow you to __________ numbers.

Compare

After the following code executes, what is the output ifuser enters 0? int x = -1; cout << "Enter a 0 or 1: "; cin >> x; if (c) -cout << "true" << endl; else -cout << "false" << endl;

False

The conditional operator takes two operands.

False

The default section is required in a switch statement.

False

The following code correctly determines whether x contains a value in the range of 0 through 100, inclusive. if (x > 0 && <= 100)

False

The value of result in the following expression will be 0 if x has the value of 12. result = x > 100 ? 0 : 1;

False

What is the output of the following code segment if the user enters 23? int number; cout << "Enter a number: "; cin >> number; if (number > 0) cout << "Hi, there!" << endl; else cout << "Good-bye." << endl;

Hi, there!

Whereas < is called a relational operator, x < y is called a?

Relational expression

If you place a semicolon after the statement: if (x < y)

The compiler will interpret the semicolon as a null statement.

What is the output of the following code segment? -int x = 5; -if (x = 2) ---cout << "This is true!" << endl; -else ---cout << "This is false!" << endl; ---cout << "That's all, folks!" << endl;

This is true! That's all folks

An expression that has any value other than 0 is considered true by an if statement.

True

As a rule of style, when writing an if statement you should indent the conditionally-executed statements.

True

Both of the following if statements perform the same operation. 1. if (sales > 10000) commissionRate = 0.15; 2. if (sales > 10000) commissionRate = 0.15;

True

If the expression on the left side of the following is false, the expression on the right side will not be checked. (a > = b) && (c == d)

True

If the expression on the left side of the following is true, the expression on the right side will not be checked. (a > = b) || (c == d)

True

You should be careful when using the equality operator to compare floating point values because of potential round-off errors.

True

What is the output of the following code segment if the user enters 90 for the score? cout << "Enter your test score: "; cin >> test_score; if (test_score < 60) cout << "You failed the test." << endl; if (test_score > 60) cout << "You passed the test." else cout << "You need to study harder next time." << endl;

You passed the test


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

intro to public speaking mid term

View Set

An Update on Demineralization/Remineralization CE

View Set

Chapter 19: Documenting and Reporting

View Set

Chapter 5: Analyzing the Audience

View Set

Families and Children (Chapter 9)

View Set