Filters
Question type

Study Flashcards

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;


A) 0
B) 3
C) 13
D) 23
E) None of these

Correct Answer

verifed

verified

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


A) a < 5 ? b = 12 : d = 30;
B) b < 5 ? b = 12 : d = 30;
C) a >= 5 ? d = 30 : b = 12;
D) d = 30 ? b = 12 : a = 5;
E) None of these

Correct Answer

verifed

verified

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;

Correct Answer

verifed

verified

True

This operator represents the logical OR:


A) --
B) ||
C) &&
D) #
E) None of these

Correct Answer

verifed

verified

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


A) true
B) False
C) -1
D) +1
E) None of these

Correct Answer

verifed

verified

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


A) parentheses ( )
B) square brackets [ ]
C) angle brackets < >
D) curly braces { }
E) None of these

Correct Answer

verifed

verified

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


A) complexity
B) overloading
C) nesting
D) validation
E) None of these

Correct Answer

verifed

verified

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


A) 12
B) 10
C) 0
D) 1
E) None of these

Correct Answer

verifed

verified

The conditional operator takes two operands.

Correct Answer

verifed

verified

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


A) true
B) False
C) -1
D) +1
E) None of these

Correct Answer

verifed

verified

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;


A) result = 0
B) result = 1
C) result = 2
D) result = 3
E) there will be no output

Correct Answer

verifed

verified

D

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;


A) nothing will be displayed
B) False
C) x
D) true
E) 0

Correct Answer

verifed

verified

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;


A) 7 15
B) 0 0
C) 10 10
D) 1 1
E) None of these

Correct Answer

verifed

verified

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";


A) 100
B) 10
C) 99
D) 0
E) all of these

Correct Answer

verifed

verified

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


A) arithmetic operator
B) relative operator
C) relational expression
D) arithmetic expression
E) None of these

Correct Answer

verifed

verified

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

Correct Answer

verifed

verified

False

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


A) switch
B) select
C) association
D) scope
E) None of these

Correct Answer

verifed

verified

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


A) the code will not compile
B) the compiler will interpret the semicolon as a null statement
C) the if statement will always evaluate to False
D) All of these are true
E) None of these

Correct Answer

verifed

verified

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


A) relational
B) logical
C) irrational
D) negation
E) None of these

Correct Answer

verifed

verified

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


A) true
B) False
C) -1
D) +1
E) None of these

Correct Answer

verifed

verified

Showing 1 - 20 of 51

Related Exams

Show Answer