COSC 1436 Test 2 Review Exam (2026) UPDATE Verified Questions And
Answers | With 100% Correct Answers graded A+ Guaranteed Success!!
When an if statement is placed within the conditionally-executed code of another if statement, this is
known as:
A. nesting
B. complexity
C. None of these
D. validation
E. overloading - (ANSWER)A. nesting
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. None of these
D. answer = 2 - (ANSWER)B. answer = 1
These operators connect two or more relational expressions into one, or reverse the logic of an
expression. - (ANSWER)logical
An expression that has any value other than 0 is considered true by and if statement. (T/F) -
(ANSWER)True
What is the value of the following expression?
true && false - (ANSWER)false
Given the if/else statement:
if (a < 5)
b = 12;
,COSC 1436 Test 2 Review Exam (2026) UPDATE Verified Questions And
Answers | With 100% Correct Answers graded A+ Guaranteed Success!!
else
d = 30;
Which of the following performs the same operation?
A. a >= 5 ? d = 30 : b = 12;
B. None of these
C. d = 30 ? b = 12 : a = 5;
D. b < 5 ? b = 12 : d = 30;
E. a < 5 ? b = 12 : d = 30; - (ANSWER)E
What is the output of the following code segment if the user enters 90 for the score?
cout << "enter your 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 harder next time." << endl;
A. You need to study harder next time.
B. You passed the test.
You need to study harder next time.
C. You failed the test.
You need to study harder next time.
D. You passed the test.
,COSC 1436 Test 2 Review Exam (2026) UPDATE Verified Questions And
Answers | With 100% Correct Answers graded A+ Guaranteed Success!!
E. You failed the test. - (ANSWER)D
You should be careful when using the equality operator to compare floating point values because of
potential round-off errors. (T/F) - (ANSWER)True
Which of the following is evaluated first, given the expression: A && B || C && !D
A. B || C
B. A && B
C. C && D
D. !D - (ANSWER)D
Relational operators allow you to ________ numbers. - (ANSWER)compare
The default section is required in a switch statement. (T/F) - (ANSWER)False
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;
, COSC 1436 Test 2 Review Exam (2026) UPDATE Verified Questions And
Answers | With 100% Correct Answers graded A+ Guaranteed Success!!
case 4: total = total + 3;
case 8: total = total + 6;
default: total = total + 4;
}
cout << total << endl; - (ANSWER)13 (Fall through adds 3, then 6, then 4)
Which line in the following program will cause a compiler error?
1 #include <iostream>
2 using namespace std;
3 int main()
4{
5 int number = 5;
6 if (number >= 0 && <= 100)
7 cout << "passed. \n";
8 else
9 cout << "failed. \n";
10 return 0;
11 } - (ANSWER)Line 6 (Missing variable "number" on the right side of the AND operator)
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. There will be no output
B. result = 3
Answers | With 100% Correct Answers graded A+ Guaranteed Success!!
When an if statement is placed within the conditionally-executed code of another if statement, this is
known as:
A. nesting
B. complexity
C. None of these
D. validation
E. overloading - (ANSWER)A. nesting
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. None of these
D. answer = 2 - (ANSWER)B. answer = 1
These operators connect two or more relational expressions into one, or reverse the logic of an
expression. - (ANSWER)logical
An expression that has any value other than 0 is considered true by and if statement. (T/F) -
(ANSWER)True
What is the value of the following expression?
true && false - (ANSWER)false
Given the if/else statement:
if (a < 5)
b = 12;
,COSC 1436 Test 2 Review Exam (2026) UPDATE Verified Questions And
Answers | With 100% Correct Answers graded A+ Guaranteed Success!!
else
d = 30;
Which of the following performs the same operation?
A. a >= 5 ? d = 30 : b = 12;
B. None of these
C. d = 30 ? b = 12 : a = 5;
D. b < 5 ? b = 12 : d = 30;
E. a < 5 ? b = 12 : d = 30; - (ANSWER)E
What is the output of the following code segment if the user enters 90 for the score?
cout << "enter your 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 harder next time." << endl;
A. You need to study harder next time.
B. You passed the test.
You need to study harder next time.
C. You failed the test.
You need to study harder next time.
D. You passed the test.
,COSC 1436 Test 2 Review Exam (2026) UPDATE Verified Questions And
Answers | With 100% Correct Answers graded A+ Guaranteed Success!!
E. You failed the test. - (ANSWER)D
You should be careful when using the equality operator to compare floating point values because of
potential round-off errors. (T/F) - (ANSWER)True
Which of the following is evaluated first, given the expression: A && B || C && !D
A. B || C
B. A && B
C. C && D
D. !D - (ANSWER)D
Relational operators allow you to ________ numbers. - (ANSWER)compare
The default section is required in a switch statement. (T/F) - (ANSWER)False
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;
, COSC 1436 Test 2 Review Exam (2026) UPDATE Verified Questions And
Answers | With 100% Correct Answers graded A+ Guaranteed Success!!
case 4: total = total + 3;
case 8: total = total + 6;
default: total = total + 4;
}
cout << total << endl; - (ANSWER)13 (Fall through adds 3, then 6, then 4)
Which line in the following program will cause a compiler error?
1 #include <iostream>
2 using namespace std;
3 int main()
4{
5 int number = 5;
6 if (number >= 0 && <= 100)
7 cout << "passed. \n";
8 else
9 cout << "failed. \n";
10 return 0;
11 } - (ANSWER)Line 6 (Missing variable "number" on the right side of the AND operator)
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. There will be no output
B. result = 3