100% found this document useful (50 votes)
480 views8 pages

C Programming From Problem Analysis To Program Design 6th Edition by Malik ISBN Test Bank

This document provides the test bank for Chapter 2 of the book "C++ Programming From Problem Analysis to Program Design 6th Edition by Malik". It includes 20 multiple choice questions, 10 true/false questions, and 4 completion questions related to basic elements of C++ such as data types, variables, operators, and input/output. The questions test understanding of concepts like data type sizes, arithmetic expressions, precedence of operators, and equivalence of assignment statements.

Uploaded by

rebecca
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
100% found this document useful (50 votes)
480 views8 pages

C Programming From Problem Analysis To Program Design 6th Edition by Malik ISBN Test Bank

This document provides the test bank for Chapter 2 of the book "C++ Programming From Problem Analysis to Program Design 6th Edition by Malik". It includes 20 multiple choice questions, 10 true/false questions, and 4 completion questions related to basic elements of C++ such as data types, variables, operators, and input/output. The questions test understanding of concepts like data type sizes, arithmetic expressions, precedence of operators, and equivalence of assignment statements.

Uploaded by

rebecca
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/ 8

Full link download C++ Programming From Problem Analysis

to Program Design 6th Edition by Malik


Test bank:
https://testbankpack.com/p/test-bank-for-c-programming-from-
problem-analysis-to-program-design-6th-edition-by-malik-isbn-
1133626386-9781133626381/

Solution manual:
https://testbankpack.com/p/solution-manual-for-c-programming-
from-problem-analysis-to-program-design-6th-edition-by-malik-
isbn-1133626386-9781133626381/

Chapter 2: Basic Elements of C++

TRUE/FALSE

1. In C++, reserved words are the same as predefined identifiers.

ANS: F PTS: 1 REF: 36

2. The maximum number of significant digits in values of the double type is 15.

ANS: T PTS: 1 REF: 42

3. The maximum number of significant digits in float values is up to 6 or 7.

ANS: T PTS: 1 REF: 42

4. An operator that has only one operand is called a unique operator.

ANS: F PTS: 1 REF: 45

5. If a C++ arithmetic expression has no parentheses, operators are evaluated from left to right.

ANS: T PTS: 1 REF: 46

6. A mixed arithmetic expression contains all operands of the same type.

ANS: F PTS: 1 REF: 49

7. Suppose a = 5. After the execution of the statement ++a; the value of a is 6.


ANS: T PTS: 1 REF: 70

8. The escape sequence \r moves the insertion point to the beginning of the next line.

ANS: F PTS: 1 REF: 78

9. A comma is also called a statement terminator.

ANS: F PTS: 1 REF: 90

10. Suppose that sum is an int variable. The statement sum += 7; is equivalent to the statement sum
= sum + 7;

ANS: T PTS: 1 REF: 95

MULTIPLE CHOICE

1. The rules of a programming language tell you which statements are legal, or accepted by the
programming language.
a. semantic c. syntax
b. logical d. grammatical
ANS: C PTS: 1 REF: 34

2. Which of the following is a reserved word in C++?


a. char c. CHAR
b. Char d. character
ANS: A PTS: 1 REF: 36
3. Which of the following is a legal identifier?
a. program! c. 1program
b. program_1 d. program 1

ANS: B PTS: 1 REF: 36

4. is a valid int value.


a. 46,259 c. 462.59
b. 46259 d. -32.00
ANS: B PTS: 1 REF: 39-40

5. is a valid char value.


a. -129 c. 128
b. ‘A’ d. 129
ANS: B PTS: 1 REF: 40

6. An example of a floating point data type is .


a. int c. double
b. char d. short
ANS: C PTS: 1 REF: 41

7. The memory allocated for a float value is bytes.


a. two c. eight
b. four d. sixteen
ANS: B PTS: 1 REF: 42
8. The value of the expression 33/10, assuming both values are integral data types, is .
a. 0.3 c. 3.0
b. 3 d. 3.3

ANS: B PTS: 1 REF: 43-44

9. The value of the expression 17 % 7 is .


a. 1 c. 3
b. 2 d. 4
ANS: C PTS: 1 REF: 43-44

10. The expression static_cast<int>(9.9) evaluates to .


a. 9 c. 9.9
b. 10 d. 9.0
ANS: A PTS: 1 REF: 51
11. The expression static_cast<int>(6.9) + static_cast<int>(7.9) evaluates to .
a. 13 c. 14.8
b. 14 d. 15
ANS: A PTS: 1 REF: 51

12. The length of the string "computer science" is .


a. 14 c. 16
b. 15 d. 18
ANS: C PTS: 1 REF: 54
13. In a C++ program, one and two are double variables and input values are 10.5 and 30.6.
After the statement cin >> one >> two; executes, .
a. one = 10.5, two = 10.5 c. one = 30.6, two = 30.6
b. one = 10.5, two = 30.6 d. one = 11, two = 31

ANS: B PTS: 1 REF: 64

14. Suppose that count is an int variable and count = 1. After the statement count++; executes,
the value of count is .
a. 1 c. 3
b. 2 d. 4
ANS: B PTS: 1 REF: 70

15. Suppose that alpha and beta are int variables. The statement alpha = --beta; is equivalent
to the statement(s) .
a. alpha = 1 - beta;
b. alpha = beta - 1;
c. beta = beta - 1;
alpha = beta;
d. alpha = beta;
beta = beta - 1;

ANS: C PTS: 1 REF: 70-71

16. Suppose that alpha and beta are int variables. The statement alpha = beta--; is equivalent
to the statement(s) .
a. alpha = 1 - beta;
b. alpha = beta - 1;
c. beta = beta - 1;
alpha = beta;
d. alpha = beta;
beta = beta - 1;
ANS: D PTS: 1 REF: 70-71

17. Suppose that alpha and beta are int variables. The statement alpha = beta++; is equivalent
to the statement(s) .
a. alpha = 1 + beta;
b. alpha = alpha + beta;
c. alpha = beta;
beta = beta + 1;
d. beta = beta + 1;
alpha = beta;
ANS: C PTS: 1 REF: 70-71

18. Suppose that alpha and beta are int variables. The statement alpha = ++beta; is equivalent
to the statement(s) .
a. beta = beta + 1;
alpha = beta;
b. alpha = beta;
beta = beta + 1;
c. alpha = alpha + beta;
d. alpha = beta + 1;
ANS: A PTS: 1 REF: 70-71

19. Choose the output of the following C++ statement:


cout << "Sunny " << '\n' << "Day " << endl;
a. Sunny \nDay
b. Sunny \nDay endl
c. Sunn
y
Day
d. Sunny
\n Day
ANS: C PTS: 1 REF: 73

20. Which of the following is the newline character?


a. \r c. \l
b. \n d. \b
ANS: B PTS: 1 REF: 73

21. Consider the following code.

// Insertion Point 1

using namespace std;


const float PI = 3.14;

int main()
{
//Insertion Point 2

float r = 2.0;
float area;
area = PI * r * r;

cout << "Area = " << area <<endl;


return 0;
}
// Insertion Point 3

In this code, where does the include statement belong?


a. Insertion Point 1 c. Insertion Point 3
b. Insertion Point 2 d. Anywhere in the program
ANS: A PTS: 1 REF: 80

22. are executable statements that inform the user what to do.
a. Variables c. Named constants
b. Prompt lines d. Expressions
ANS: B PTS: 1 REF: 91

23. The declaration int a, b, c; is equivalent to which of the following?


a. inta , b, c; c. int abc;
b. int a,b,c; d. int a b c;
ANS: B PTS: 1 REF: 92

24. Suppose that alpha and beta are int variables and alpha = 5 and beta = 10. After the
statement alpha *= beta; executes, .
a. alpha = 5 c. alpha = 50
b. alpha = 10 d. alpha = 50.0
ANS: C PTS: 1 REF: 94

25. Suppose that sum and num are int variables and sum = 5 and num = 10. After the statement
sum += num executes, .
a. sum = 0 c. sum = 10
b. sum = 5 d. sum = 15
ANS: D PTS: 1 REF: 95

COMPLETION

1. is the process of planning and creating a program.

ANS:
Programming
programming

PTS: 1 REF: 28

2. A(n) is a memory location whose contents can be

changed. ANS: variable

PTS: 1 REF: 33

3. A(n) is a collection of statements, and when it is activated, or executed,


it accomplishes something.

ANS:
subprogram
sub program
sub-program
function
modlue
PTS: 1 REF: 34

4. functions are those that have already been written and are provided as part
of the system.

ANS:
Predefined
predefined
Standard
standard

PTS: 1 REF: 34

5. rules determine the meaning of instructions.

ANS:
Semantic
semantic

PTS: 1 REF: 34

6. can be used to identify the authors of the program, give the date when the
program is written or modified, give a brief explanation of the program, and explain the meaning
of key statements in a program.

ANS:
Comments
comments

PTS: 1 REF: 34

7. The smallest individual unit of a program written in any language is called a(n)
.

ANS: token

PTS: 1 REF: 35

8. In a C++ program, are used to separate special symbols, reserved words,


and identifiers.

ANS:
whitespaces
whitespace
white spaces
white space

PTS: 1 REF: 37

9. The type is C++ ’s method for allowing programmers to create their


own simple data types.

ANS: enumeration
PTS: 1 REF: 38

10. The memory space for a(n) data value is 64 bytes.

ANS: long long

PTS: 1 REF: 39

11. The maximum number of significant digits is called the

. ANS: precision

PTS: 1 REF: 42

12. When a value of one data type is automatically changed to another data type, a(n)
type coercion is said to have occurred.

ANS: implicit

PTS: 1 REF: 51

13. A(n) is a sequence of zero or more

characters. ANS: string

PTS: 1 REF: 53

14. In C++, you can use a(n) to instruct a program to mark those
memory locations in which data is fixed throughout program execution.

ANS:
named constant
constant

PTS: 1 REF: 55

15. A data type is called if the variable or named constant of that type can
store only one value at a time.

ANS: simple

PTS: 1 REF: 57

You might also like