Exam 4: Making Decisions

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

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

Free
(True/False)
4.8/5
(29)
Correct Answer:
Verified

False

Given the following code segment, what is the output? int x = 1, y = 1, z = 1; y = y + z; x = x + y; cout << "result = " << (x < y ? y : x) << endl;

Free
(Multiple Choice)
5.0/5
(38)
Correct Answer:
Verified

D

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

Free
(True/False)
4.9/5
(36)
Correct Answer:
Verified

True

The conditional operator takes two operands.

(True/False)
4.9/5
(36)

This statement uses the value of a variable or expression to determine where the program will branch to.

(Multiple Choice)
4.8/5
(36)

If you intend to place a block of statements within an if statement, you must place __________ around the block:

(Multiple Choice)
4.9/5
(29)

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

(Multiple Choice)
4.7/5
(37)

Given the if/else statement: If (a < 5) B = 12; Else D = 30; Which of the following performs the same operation?

(Multiple Choice)
4.9/5
(28)

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

(Multiple Choice)
4.9/5
(35)

What is the value of donuts after the following statement executes? int donuts = 10; if (donuts = 1) \quad donuts = 0; else \quad donuts += 2;

(Multiple Choice)
4.8/5
(36)

What is the value of the following expression? True && true

(Multiple Choice)
4.9/5
(39)

What is the value of the following expression? True || False

(Multiple Choice)
5.0/5
(36)

Whereas < is called a relational operator, x < y is called a(n)

(Multiple Choice)
4.7/5
(34)

What will be displayed after the following statements execute? int funny = 7, serious = 15; funny = serious % 2; if (funny != 1) { \quad funny = 0; \quad serious = 0; } else if (funny == 2) { \quad funny = 10; \quad serious = 10; } else { \quad funny = 1; \quad serious = 1; } cout << funny << " " << serious << endl;

(Multiple Choice)
4.9/5
(37)

This operator represents the logical OR:

(Multiple Choice)
4.8/5
(30)

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

(Multiple Choice)
4.9/5
(34)

Which value can be entered to cause the following code segment to display the message "That number is acceptable"? Int number; Cin >> number; If (number > 10 && number < 100) Cout << "That number is acceptable.\n"; Else Cout << "That number is not acceptable.\n";

(Multiple Choice)
4.8/5
(35)

What is the value of the following expression? True && False

(Multiple Choice)
4.8/5
(34)

What is the output of the following segment of code if the value 4 is input by the user? int num; int total = 0; cout << "Enter a number from 1 to 10: "; cin >> num; switch (num) { case 1: case 2: \quad total = 5; case 3: \quad total = 10; case 4: \quad total = total + 3; Case 8: \quad total = total + 6; default: \quad total = total + 4; } cout << total << endl;

(Multiple Choice)
4.9/5
(25)

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

(Multiple Choice)
4.8/5
(34)
Showing 1 - 20 of 51
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)