Exam 4: Making Decisions
Exam 1: Introduction to Computers and Programming47 Questions
Exam 2: Introduction to C62 Questions
Exam 3: Expressions and Interactivity45 Questions
Exam 4: Making Decisions51 Questions
Exam 5: Loops and Files60 Questions
Exam 6: Functions49 Questions
Exam 7: Arrays and Vectors56 Questions
Exam 8: Searching and Sorting Arrays30 Questions
Exam 9: Pointers47 Questions
Exam 10: Characters, C-Strings, and More About the String Class47 Questions
Exam 11: Structured Data46 Questions
Exam 12: Advanced File Operations38 Questions
Exam 13: Introduction to Classes54 Questions
Exam 14: More About Classes46 Questions
Exam 15: Inheritance, Polymorphism, and Virtual Functions43 Questions
Exam 16: Exceptions and Templates36 Questions
Exam 17: The Standard Template Library38 Questions
Exam 18: Linked Lists41 Questions
Exam 19: Stacks and Queues47 Questions
Exam 20: Recursion27 Questions
Exam 21: Binary Trees39 Questions
Select questions type
The following code correctly determines whether x contains a value in the range of 0 through 100, inclusive.
if (x > 0 && <= 100)
Free
(True/False)
4.8/5
(29)
Correct Answer:
False
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;
Free
(Multiple Choice)
5.0/5
(38)
Correct Answer:
D
Both of the following if statements perform the same operation.
1. if (sales > 10000)
commissionRate = 0.15;
2. if (sales > 10000) commissionRate = 0.15;
Free
(True/False)
4.9/5
(36)
Correct Answer:
True
This statement uses the value of a variable or expression to determine where the program will branch to.
(Multiple Choice)
4.8/5
(36)
If you intend to place a block of statements within an if statement, you must place __________ around the block:
(Multiple Choice)
4.9/5
(29)
Given the if/else statement:
If (a < 5)
B = 12;
Else
D = 30;
Which of the following performs the same operation?
(Multiple Choice)
4.9/5
(28)
These operators connect two or more relational expressions into one, or reverse the logic of an expression.
(Multiple Choice)
4.9/5
(35)
What is the value of donuts after the following statement executes?
int donuts = 10;
if (donuts = 1)
donuts = 0;
else
donuts += 2;
(Multiple Choice)
4.8/5
(36)
What is the value of the following expression?
True && true
(Multiple Choice)
4.9/5
(39)
What is the value of the following expression?
True || False
(Multiple Choice)
5.0/5
(36)
Whereas < is called a relational operator, x < y is called a(n)
(Multiple Choice)
4.7/5
(34)
What will be displayed after the following statements execute?
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;
(Multiple Choice)
4.9/5
(37)
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)
cout << "true" << endl;
else
cout << "False" << endl;
(Multiple Choice)
4.9/5
(34)
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";
(Multiple Choice)
4.8/5
(35)
What is the value of the following expression?
True && False
(Multiple Choice)
4.8/5
(34)
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:
total = 5;
case 3:
total = 10;
case 4:
total = total + 3;
Case 8:
total = total + 6;
default:
total = total + 4;
}
cout << total << endl;
(Multiple Choice)
4.9/5
(25)
When an if statement is placed within the conditionally-executed code of another if statement, this is known as
(Multiple Choice)
4.8/5
(34)
Showing 1 - 20 of 51
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)