Exam 4: Making Decisions
Exam 1: Introduction to Computers and Programming44 Questions
Exam 2: Introduction to C++56 Questions
Exam 3: Expressions and Interactivity44 Questions
Exam 4: Making Decisions53 Questions
Exam 5: Loops and Files62 Questions
Exam 6: Functions49 Questions
Exam 7: Arrays53 Questions
Exam 8: Searching and Sorting Arrays20 Questions
Exam 10: Characters, C++-Strings, and More About the String Class42 Questions
Exam 11: Structured Data43 Questions
Exam 11: Structured Data50 Questions
Exam 12: Advanced File Operations38 Questions
Exam 13: Introduction to Classes46 Questions
Exam 14: More About Classes40 Questions
Exam 15: Inheritance, Polymorphism, and Virtual Functions38 Questions
Exam 16: Exceptions, Templates, and the Standard Template Library STL39 Questions
Exam 17: Linked Lists40 Questions
Exam 18: Stacks and Queues46 Questions
Exam 19: Recursion21 Questions
Exam 20: Binary Trees38 Questions
Select questions type
What is the value of donuts after the following code executes?
int donuts = 10;
if (donuts = 1)
donuts = 0;
else
donuts += 2;
(Multiple Choice)
4.7/5
(86)
This operator takes an operand and reverses its truth or falsehood.
(Multiple Choice)
4.9/5
(90)
The following code correctly determines whether x contains a value in the range of 0 through 100.
if (x >= 0 && <= 100)
(True/False)
4.9/5
(80)
What is the output of the following segment of code if 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;
case 4: total = total + 3;
case 8: total = total + 6;
default: total = total + 4;
}
cout << total << endl;
(Multiple Choice)
4.9/5
(77)
The ________ of a variable is limited to the block in which it is declared.
(Multiple Choice)
4.9/5
(93)
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 = 1;
serious = 1;
}
Cout << funny << " " << serious << endl;
(Multiple Choice)
4.7/5
(75)
If the sub-expression on the left side of an && operator is false, the expression on the right side will not be checked.
(True/False)
4.9/5
(77)
Which line in the following program will cause a compiler error? 1 #include <iostream>
2 using namespace std;
3
4 int main()
5 {
6 int number = 5;
7
8 if (number >= 0 && <= 100)
9 cout << "passed.\n";
10 else
11 cout << "failed.\n";
12 return 0;
13 }
(Multiple Choice)
5.0/5
(87)
Both of the following if statements perform the same operation.
if (sales > 10000)
commissionRate = 0.15;
if (sales > 10000) commissionRate = 0.15;
(True/False)
4.7/5
(76)
Which of the following expressions will determine whether x is less than or equal to y?
(Multiple Choice)
5.0/5
(87)
If you intend to place a block of statements within an if statement, you must place these around the block.
(Multiple Choice)
4.8/5
(89)
You should be careful when using the equality operator to compare floating point values because of potential round-off errors.
(True/False)
4.7/5
(72)
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?
(Multiple Choice)
4.9/5
(84)
After execution of the following code, what will be the value of input_value if the value 0 is entered at the keyboard 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;
(Multiple Choice)
4.8/5
(86)
Without this statement appearing in a switch construct, the program "falls through" all of the statements below the one with the matching case expression.
(Multiple Choice)
4.8/5
(69)
What will the following program display? #include <iostream>
using namespace std;
int main()
{
int a = 0, b = 2, x = 4, y = 0;
cout << (a == b) << " ";
cout << (a != b) << " ";
cout << (b <=x) << " ";
cout << (y > a) << endl;
return 0;
}
(Multiple Choice)
4.8/5
(73)
Given the following code segment, what is output after "result = "? int x = 1, y = 1, z = 1;
y= y + z;
x = x + y;
cout << "result = " << (x < y ? y : x) << endl;
(Multiple Choice)
4.8/5
(82)
Showing 21 - 40 of 53
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)