Week 2: Knowledge Check

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

This operator represents the logical AND.

&&

This operator will decrement a value by one.

--

What will be the value of input_value if the value 0 is input 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 the following code display? int x = 0; for (int count = 0; count < 3; count++) x += count; cout << x << endl;

3

What will the following code display? int x = 0; for (int num = 0; num < 3; num++) x += num; cout << x << endl;

3

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 "Y" and then output "This is a check" and then advance to a new line?

If (code == 'Y') cout << "This is a check\n";

_____ occurs when the program lets the user know that an invalid input choice has been made.

Input validation

This operator will increment a value by one.

NOT --

What will be the value of input_value if the value 2 is input 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;

NOT 10

hat will be the value of input_value if the value 2 is input 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;

NOT 25

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?

NOT If (code = "C") cout << "This is a check" << endl; NOT If (code == C) cout << "This is a check" << endl;

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

NOT output correction.

Input values should always be checked for

NOT reasonableness. NOT appropriate range.

The do-while loop is a loop that is ideal in situations where you always want the loop to iterate at least once.

Post-Test

Something within a while loop must eventually cause the condition to become false or a(n) _____ results.

infinite loop

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

nesting.

This operator represents the logical OR.

||

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 = 2; serious = 2; } cout << funny << " " << serious << endl;}

2 2

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 = 3;serious = 3;}cout << funny << " " << serious << endl;} Group of answer choices

3.3

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

NOT If code is equal to X cout << "This is a check\n";

The for loop is this type of loop.

NOT Infinite

The while loop is this type of loop.

NOT Infinite

he do-while loop is a loop that is ideal in situations where you always want the loop to iterate at least once.

NOT Infinite

A loop that is inside another loop is called

NOT Infinite loop NOT a pre-test loop.

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

NOT Square brackets [] NOT Angle brackets < >

The control statement that causes a statement or group of statements to repeat is

NOT cout. NOT decision statement.

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

NOT output correction.


Kaugnay na mga set ng pag-aaral

chapter 13 - retailing & wholesaling

View Set

Real Estate - LAW quiz questions

View Set

IT ENGLISH: DS Terms & Definitions (English-English) *WORK IN PROGRESS

View Set

Strategic Management Chapters 1, 4, 5, 7, 6

View Set