Filters
Question type

Study Flashcards

This operator is known as the logical OR operator.


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

F) B) and D)
G) B) and C)

Correct Answer

verifed

verified

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;


A) This is true!
B) This is false!
C) This is true!
This is false!
D) This is true!
This is all folks!
E) None of these

F) A) and D)
G) A) and C)

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

F) All of the above
G) D) and E)

Correct Answer

verifed

verified

B

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


A) input validation
B) output correction
C) compiler criticism
D) output validation
E) None of these

F) B) and E)
G) A) and B)

Correct Answer

verifed

verified

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;


A) C++ is fun
B) Soccer is fun
C) C++
D) C++fun
E) Soccerfun

F) B) and C)
G) A) and E)

Correct Answer

verifed

verified

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;


A) This is a test question!
B) Congratulations!
That's a high score!
This is a test question!
C) That's a high score!
This is a test question!
D) Congratulations!
That's a high score!
E) None of these

F) A) and B)
G) A) and C)

Correct Answer

verifed

verified

The default section is required in a switch statement.

A) True
B) False

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 the above.
E) None of these.

F) A) and D)
G) A) and E)

Correct Answer

verifed

verified

This operator performs a logical NOT operation.


A) --
B) !
C) <>
D) ><
E) None of these

F) None of the above
G) B) and D)

Correct Answer

verifed

verified

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;


A) Nothing will be displayed
B) false
C) x
D) true

E) All of the above
F) B) and C)

Correct Answer

verifed

verified

B

Input values should always be checked for


A) Appropriate range
B) Reasonableness
C) Division by zero, if division is taking place
D) All of these
E) None of these

F) C) and D)
G) A) and C)

Correct Answer

verifed

verified

D

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


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

F) C) and D)
G) A) and B)

Correct Answer

verifed

verified

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;


A) 10
B) 7
C) The string "x >= y"
D) 1
E) 0

F) A) and C)
G) All of the above

Correct Answer

verifed

verified

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


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

F) A) and B)
G) B) and E)

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

F) B) and E)
G) A) and C)

Correct Answer

verifed

verified

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

A) True
B) False

Correct Answer

verifed

verified

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


A) true
B) false
C) -1
D) +1

E) A) and B)
F) B) and D)

Correct Answer

verifed

verified

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


A) answer = 0
B) answer = 1
C) answer = 2
D) None of these

E) B) and D)
F) A) and D)

Correct Answer

verifed

verified

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

A) True
B) False

Correct Answer

verifed

verified

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


A) You failed the test!
B) You passed the test!
C) You failed the test!
You passed the test!
D) You failed the test!
You did poorly on the test!
E) None of the above

F) B) and D)
G) B) and C)

Correct Answer

verifed

verified

Showing 1 - 20 of 53

Related Exams

Show Answer