0% found this document useful (0 votes)
122 views6 pages

False B. False C. True False: Engineering Problem Solving With C++, 3e Chapter 3 Test Bank

This document contains a chapter test bank with multiple choice questions about C++ operators, control structures, algorithms, and problem solving concepts. There are 23 questions testing knowledge of relational, logical, and assignment operators as well as control structures like if/else statements and switch cases. The test also covers algorithm design, structured programming, and operator overloading in C++.

Uploaded by

noora
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
122 views6 pages

False B. False C. True False: Engineering Problem Solving With C++, 3e Chapter 3 Test Bank

This document contains a chapter test bank with multiple choice questions about C++ operators, control structures, algorithms, and problem solving concepts. There are 23 questions testing knowledge of relational, logical, and assignment operators as well as control structures like if/else statements and switch cases. The test also covers algorithm design, structured programming, and operator overloading in C++.

Uploaded by

noora
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Engineering Problem Solving with C++, 3e Chapter 3 Test Bank

1. Evaluate the following expressions.


A. 13 < 6 false
B. (7 > 9) && (6 != 5) false
C. (4 < 3) || (4 >= 0) true
D. !('F' < 'M') false

2. What is the correct output from the following program?


#include <iostream>
using namespace std;
int main()
{ int A, B;
A = 6;
B = 1;
if (A > B)
{ A = A * B + 2;
B ++;
}
else
{ A = A / 2;
B = B + 4;
}
cout << “A = “ << A << “ B = “ << B;
return 0;
}
A. A = 8 B = 2 C. A = 4 B = 6
B. A = 3 B = 5 D. None of the above is correct

©2017 Pearson Education, Inc. Hoboken, NJ. All Rights Reserved.


Engineering Problem Solving with C++, 3e Chapter 3 Test Bank

3. What is the output of the following program?


#include <iostream>
using namespace std;
int main()
{ int Num, X, Y;
Num = 4;
X = 5;
Y = 6;
switch (Num)
{ case 1: X = Num;
break;
case 2: Y = Y + 3;
case 3: X = Num + 4;
break;
case 4: X = X * 3;
default: Y = Y - 3;
}
cout << "X = " << X << " and Y = " << Y;
return 0;
}
A. X = 4 and Y = 6 D. X = 15, Y = 6
B. X = 8 and Y = 9 E. None of the above are correct
C. X = 15 and Y = 3

©2017 Pearson Education, Inc. Hoboken, NJ. All Rights Reserved.


Engineering Problem Solving with C++, 3e Chapter 3 Test Bank

4. What is the output of the following program?


#include <iostream>
using namespace std;
int main()
{ int X, Y;
X = 30;
if (X <= 5)
{ Y = X * X;
X = X + 5;
}
else
{ if (X < 10)
Y = X - 2;
else if (X < 25)
Y = X + 10;
else
Y = X / 10;
X++;
}
cout << “Y = “ << Y << “; X = “ << X;
return 0;
}
A. Y = 3, X = 31
B. Y = 28, X =31
C. Y = 40, X = 31
D. Y = 900, X = 35
E. None of the above are correct

©2017 Pearson Education, Inc. Hoboken, NJ. All Rights Reserved.


Engineering Problem Solving with C++, 3e Chapter 3 Test Bank

5. Which of the following operators is a relational operator


A. !
B. &&
C. =
D. <=
6. Which of the following operators is a logical operator
A. !
B. &&
C. =
D. <=

7. Which of the following operators has the highest precedence?


A. !
B. &&
C. =
D. <=
8. The operator = is used to determine whether the left hand operand is equivalent to the right
hand operand.
A. True
B. False
9. The value which follows the word case in a switch statement can be of type integer or
character.
A. True
B. False
10. The operands of the operator || must both be Boolean values.
A. True
B. False
11. A blank space can be placed between the ampersands in the logical operator && to make it
more readable.
A. True
B. False

12. Linear interpolation is used to …


A. approximate a value outside of the range of known data values by determining a line
which best fits the entire data set.
B. approximate a value outside of the range of known data values by extending the line
which connects the last two known data points.
C. approximate a value inside of the range of known data values by determining a line
which best fits the entire data set.
D. approximate a value inside of the range of know data values by connecting adjacent
points in the data set with a line.

©2017 Pearson Education, Inc. Hoboken, NJ. All Rights Reserved.


Engineering Problem Solving with C++, 3e Chapter 3 Test Bank

13. Which of the following are characteristics of a good algorithm:


A. Improved quality of the solution.
B. Improved maintainability of a solution.
C. Reduced implementation time.
D. All of these are characteristics of a good algorithm.

14. An algorithm is a sequence of steps for solving a problem.


A. True
B. False

15. Top-down design begins with a ‘big picture’ description of a problem solution in sequential
steps; the sequential steps are repeatedly refined until the steps are detailed enough to
translate to computer language statements.
A. True
B. False

16. Structured programming requires the use of complex control structures.


A. True
B. False

17. In C++, the = and == operators perform identical operations and may be used
interchangeably.
A. True
B. False

18. Which of the following C++ operators performs logical not equal:
A. <>
B. ~=
C. !=
D. None of these are logical not equal in C++.

19. Complete the true table for C++ logical operators.


A B A&&B A||B !A !B

false false false false true true


false true false true true false
true false false true false true
true true true true false false

20. C++ only evaluates as much of a logical expression as necessary to evaluate it; this is called
short-circuit evaluation.
A. True
B. False

©2017 Pearson Education, Inc. Hoboken, NJ. All Rights Reserved.


Engineering Problem Solving with C++, 3e Chapter 3 Test Bank

21. C++ allows overloading operators when working with programmer defined types.
A. True
B. False

22. C++ allows the programmer to overload operators for standard C++ data types.
A. True
B. False

23. The control expression in C++ switch statements may be of type string.
A. True
B. False

©2017 Pearson Education, Inc. Hoboken, NJ. All Rights Reserved.

You might also like