Exam 4: Making Decisions

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

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

(Multiple Choice)
4.7/5
(86)

This operator takes an operand and reverses its truth or falsehood.

(Multiple Choice)
4.9/5
(90)

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

(True/False)
4.9/5
(80)

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

(Multiple Choice)
4.9/5
(77)

The ________ of a variable is limited to the block in which it is declared.

(Multiple Choice)
4.9/5
(93)

What will the following program segment display? 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.7/5
(75)

This operator is used in C++ to represent equality.

(Multiple Choice)
4.8/5
(71)

In C++ the = operator indicates

(Multiple Choice)
4.8/5
(75)

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

(True/False)
4.9/5
(77)

Which line in the following program will cause a compiler error? 1 \quad #include <iostream> 2 \quad using namespace std; 3 4 \quad int main() 5 \quad { 6 \quad\quad int number = 5; 7 8 \quad\quad if (number >= 0 && <= 100) 9 \quad\quad\quad cout << "passed.\n"; 10 \quad\quad else 11 \quad\quad\quad cout << "failed.\n"; 12 \quad\quad return 0; 13 \quad }

(Multiple Choice)
5.0/5
(87)

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

(True/False)
4.7/5
(76)

Which of the following expressions will determine whether x is less than or equal to y?

(Multiple Choice)
5.0/5
(87)

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

(Multiple Choice)
4.8/5
(89)

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

(True/False)
4.7/5
(72)

x <= (y * 2)

(Multiple Choice)
4.8/5
(95)

Which statement allows you to properly check the char variable code to determine whether it is equal to a "C" and then output "This is a check" and then advance to a new line?

(Multiple Choice)
4.9/5
(84)

After execution of the following code, what will be the value of input_value if the value 0 is entered at the keyboard at run time? cin >> input_value; if (input_value > 5) \quad input_value = input_value + 5; else if (input_value > 2) \quad input_value = input_value + 10; else \quad input_value = input_value + 15;

(Multiple Choice)
4.8/5
(86)

Without this statement appearing in a switch construct, the program "falls through" all of the statements below the one with the matching case expression.

(Multiple Choice)
4.8/5
(69)

What will the following program display? #include <iostream> using namespace std; int main() { \quad int a = 0, b = 2, x = 4, y = 0; \quad cout << (a == b) << " "; \quad cout << (a != b) << " "; \quad cout << (b <=x) << " "; \quad cout << (y > a) << endl; \quad return 0; }

(Multiple Choice)
4.8/5
(73)

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

(Multiple Choice)
4.8/5
(82)
Showing 21 - 40 of 53
close modal

Filters

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