Exam 4: Making Decisions

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

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

Free
(Multiple Choice)
4.9/5
(78)
Correct Answer:
Verified

B

Input values should always be checked for

Free
(Multiple Choice)
4.8/5
(60)
Correct Answer:
Verified

D

What will be the output of the following code segment after the user enters 0 at the keyboard? int x = -1; cout << "Enter a 0 or a 1 from the keyboard: "; cin >> x; if (x) \quad cout << "true" << endl; else \quad cout << "false" << endl;

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

B

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

(True/False)
4.8/5
(78)

When a program lets the user know that an invalid choice has been made, this is known as:

(Multiple Choice)
4.8/5
(83)

What will the following segment of code output if 11 is entered at the keyboard? int number; cin >> number; if (number > 0) \quad cout << "C++"; else \quad cout << "Soccer"; cout << " is "; cout << "fun" << endl;

(Multiple Choice)
4.7/5
(68)

What will following segment of code output? int x = 5; If (x = 2) \quad cout << "This is true!" << endl; else \quad cout << "This is false!" << endl; cout << "This is all folks!" << endl;

(Multiple Choice)
4.8/5
(87)

What will the following segment of code output? You can assume the user enters a grade of 90 from the keyboard. cout << "Enter a test score: "; cin >> test_score; if (test_score < 60); \quad cout << "You failed the test!" << endl; if (test_score > 60) \quad cout << "You passed the test!" << endl; else \quad cout << "You need to study for the next test!";

(Multiple Choice)
4.7/5
(75)

This operator is known as the logical OR operator.

(Multiple Choice)
4.8/5
(90)

The default section is required in a switch statement.

(True/False)
4.8/5
(76)

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) \quad cout << "That number is acceptable.\n"; else \quad cout << "That number is not acceptable.\n";

(Multiple Choice)
4.9/5
(91)

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

(True/False)
4.8/5
(81)

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

(Multiple Choice)
4.9/5
(80)

This operator performs a logical NOT operation.

(Multiple Choice)
4.9/5
(79)

What will the following segment of code output? score = 40; if (score > 95) \quad cout << "Congratulations!\n"; cout << "That's a high score!\n"; cout << "This is a test question!" << endl;

(Multiple Choice)
4.9/5
(79)

Given that x = 2, y = 1, and z = 0, what will the following cout statement display? cout << "answer = " << (x || !y && z) << endl;

(Multiple Choice)
4.8/5
(96)

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

(Multiple Choice)
4.9/5
(88)

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

(Multiple Choice)
4.8/5
(77)

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

(Multiple Choice)
4.7/5
(63)

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

(Multiple Choice)
4.8/5
(69)
Showing 1 - 20 of 53
close modal

Filters

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