Quiz 4

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

This operator performs a logical NOT operation.

!

This operator represents the logical AND.

&&

When a relational expression is false, it has the value ________.

0

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

0110

What is the output of the following code? int w = 98; int x = 99; int y = 0; int z = 1; If (x >= 99) { If (x < 99) cout << y << endl; else cout << z << endl; } else { if (x == 99) cout << x << endl; else cout << w << endl; }

1

What will the following program segment display? int funny = 7, serious = 15; funny = serious % 2; If (funny != 1) { funny = 0; serious = 0; } else if (funny == 2) { funny = 10; serious = 10; } else { funny = 1; serious = 1; } cout << funny << " " << serious << endl;

1 1

What is the output of the following segment of code if the value 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;

13

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) input_value = input_value + 5; else if (input_value > 2) input_value = input_value + 10; else input_value = input_value + 15;

15

What will be the value of result after the following code has been executed? int a = 60; int b = 15; int result = 10; If (a = b) result *= 2;

20

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

==

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?

If (code == 'C') cout << "this is a check" << endl;

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

Relational expression

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

That's a high score! This is a test question!

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 << "this is all folks!" << endl;

This is true! This is all folks!

What will be the following segment of code output? Assume the user enters a grade of 90 from the keyboard. cout << "enter a test score: "; cin >> test_score; If (test_score < 60); cout << "you failed the test!" << endl; If (test_score > 60) cout << "you passed the test!" << endl; else cout << "you need to study for the next test!";

You failed the test! You passed the test!

In C++ the = operator indicates:

assignment

Relational operators allow you to _______ numbers.

compare

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) cout << "true" << endl; else cout << "false" << endl;

false

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

nesting

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

scope


Kaugnay na mga set ng pag-aaral

BioMed Activity 3.2.6 In Search of Energy

View Set

Metric Prefix (largest to smallest).

View Set

Chapter 7 - Consumer Buying Behavior, Chapter 8 - Business Markets and Buying Behavior, Chapter 9 - Reaching Global Markets, Chapter 10 - Product Concepts, Chapter 6 - Target Markets: Segmentation, Evaluation, and Positioning

View Set

Chapter 1 Computer Security Principles and Practice (Stallings/Brown)

View Set

Google IT Support Professional Certificate: IT Security: Defense against the digital dark arts. Week 5

View Set

Health Policy Provisions, Clauses, and Riders

View Set

CDX Chapter 30 (meter usage and circuit diagnosis)

View Set