Exam 2: Flow of Control
Exam 1: C++ Basics37 Questions
Exam 2: Flow of Control33 Questions
Exam 3: Function Basics30 Questions
Exam 4: Parameters and Overloading31 Questions
Exam 5: Arrays32 Questions
Exam 6: Structures and Classes37 Questions
Exam 7: Constructors and Other Tools32 Questions
Exam 8: Operator Overloading,friends,and References31 Questions
Exam 9: Strings37 Questions
Exam 10: Pointers and Dynamic Arrays29 Questions
Exam 11: Separate Compilation and Namespaces35 Questions
Exam 12: Streams and File IO43 Questions
Exam 13: Recursion40 Questions
Exam 14: Inheritance30 Questions
Exam 15: Polymorphism and Virtual Functions34 Questions
Exam 16: Templates27 Questions
Exam 17: Linked Data Structures30 Questions
Exam 18: Exception Handling29 Questions
Exam 19: Standard Template Library46 Questions
Exam 20: Patterns and Uml22 Questions
Select questions type
The if,while and for statements control only one statement.
Free
(True/False)
4.8/5
(37)
Correct Answer:
True
You want to determine whether time has run out.The following code correctly implements this.
!time > limit
Free
(True/False)
4.9/5
(33)
Correct Answer:
False
Write multiway if-else statements for which the output is "Alarm: Boiler Pressure: TOO HIGH" if the value of the variable boiler_pressure is greater than 1000 (psi),and the output is "Boiler Pressure: TOO LOW" if the value of boiler_pressure is below 100(psi),otherwise the output is "Boiler Pressure: within normal limits."
Free
(Essay)
4.9/5
(45)
Correct Answer:
if (boiler_pressure > 1000)
cout << "Boiler Pressure: TOO LOW\n";
else if (boiler_pressure < 100)
cout << "Boiler Pressure: TOO LOW\n";
else
cout << "Boiler Pressure: within normal limits.\n";
Which of the following determines the operator that is processed prior to another operator?
(Multiple Choice)
4.8/5
(40)
Assume variables first and second are declared to be double and are initialized.Write a sequence of lines of code that cause the values stored in first and second to be exchanged if the value of first is not less than second.
(Essay)
4.8/5
(44)
If the following code fragment is executed in an otherwise complete and correct program,which expression will be executed? Why? x = 0;
If (x = 12)
Yes_statement;
Else
No_statement;
(Multiple Choice)
4.8/5
(41)
Predict the output of the following nested loops:
int n = 1;
while(n <= 10)
{
int m = 10;
while(m>=1)
{
cout << n << " times " << m
<< " = " << n*m << endl;
m--;
}
n++;
}
(Essay)
4.7/5
(30)
Given the declaration
int x = 0;
The following expression causes a divide by zero error:
(x !=0)|| (2/x < 1);
(True/False)
5.0/5
(30)
Assume variables first,second,and max are declared to be double and are initialized.Write a sequence of lines of code that cause the larger of the values in first and second to be stored in max.
(Essay)
4.9/5
(45)
The value of count is 0;limit is 10.Evaluate:
(count == 0)&&(limit < 20)
(True/False)
4.9/5
(37)
In the expression (j > 0 && j+1 == 10),which operator executes last?
(Multiple Choice)
4.8/5
(42)
Write Boolean expressions that represent the given English expressions.Assume any variables used have been declared and initialized.
a)at least one of x or y is odd
b)at least one of x or y is non-negative (x is non-negative is written x >= 0)
c)The hit is no more than 2.5 units away from target
d)x is 1 or x is equal to y
e)t is strictly between 3.2 and 3.3
(Essay)
4.8/5
(44)
Write a program that reads in exactly 10 integers and outputs the sum.
(Essay)
4.7/5
(32)
Explain the programmer's saying from the text,section 2.2,"Garbage in means garbage out."
(Essay)
4.9/5
(32)
Write multiway if-else statements in which letter grades are assigned based a numeric grade based on this "ten point" scheme:
if the numeric grade is not less than 90,the letter grade is an A,
if the numeric grade is not less than 80,the letter grade is a B,
if the numeric grade is not less than 70,the letter grade is C,
if the numeric grade is not less than 60,the letter grade is D,
otherwise the letter grade is F.
(Essay)
5.0/5
(38)
The value of count is 0;limit is 10.Evaluate:
count == 0 && limit < 20
(True/False)
4.8/5
(42)
Use the condition operator (x?y:z)to write a very compact expression that assigns the maximum of variables n1 and n2 to the variable max.You should assume that any variables you use have been declared and initialized appropriately.
(Essay)
4.8/5
(46)
Consider the if statement: if(condition)yes_clause;else no_clause;
Under which of the following circumstances will both the yes_clause and the no_clause will be executed?
(Multiple Choice)
4.8/5
(37)
Showing 1 - 20 of 33
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)