Starting Out With C From Control Structures Through Objects Brief Version 8th Edition Gaddis Test Bank
Starting Out With C From Control Structures Through Objects Brief Version 8th Edition Gaddis Test Bank
2
Copyright © 2015 Pearson Education, Inc.
6) represent storage locations in the computer's memory.
A) Literals
B) Variables
C) Comments
D) Integers
E) None of the above
Answer: B
7) These are data items whose values do not change while the program is running.
A) Literals
B) Variables
C) Comments
D) Integers
E) None of the above
Answer: A
8) You must have a for every variable you intend to use in a program.
A) purpose
B) definition
C) comment
D) constant
E) None of the above
Answer: B
10) The numeric data types in C++ can be broken into two general categories:
A) numbers and characters
B) singles and doubles
C) integer and floating point
D) real and unreal
E) None of the above
Answer: C
11) Besides decimal, two other number systems you might encounter in C++ programs are:
A) Octal and Fractal
B) Hexadecimal and Octal
C) Unary and Quaternary
D) Base 7 and Base 9
E) None of the above
Answer: B
3
Copyright © 2015 Pearson Education, Inc.
12) A character literal is enclosed in quotation marks, whereas a string literal is enclosed in
quotation marks.
A) double, single
B) triple, double
C) open, closed
D) single, double
E) None of the above
Answer: D
14) Which escape sequence causes the cursor to move to the beginning of the current line?
A) \n
B) \t
C) \a
D) \b
E) \r
Answer: E
16) Which data type typically requires only one byte of storage?
A) short
B) int
C) float
D) char
E) double
Answer: D
4
Copyright © 2015 Pearson Education, Inc.
17) What is the output of the following statement?
A) 15
B) 12
C) 63
D) 72
E) None of these
Answer: B
18) In programming terms, a group of characters inside a set of quotation marks is called a(n):
A) String literal
B) Variable
C) Operation
D) Statement
E) None of the above
Answer: A
19) This is used to mark the end of a complete C++ programming statement.
A) Pound Sign
B) Semicolon
C) Data type
D) Void
E) None of the above
Answer: B
21) must be included in any program that uses the cout object.
A) Opening and closing braces
B) The header file iostream
C) Comments
D) Escape sequences
E) None of the above
Answer: B
5
Copyright © 2015 Pearson Education, Inc.
22) If you use a C++ key word as an identifier, your program will:
A) Execute with unpredictable results
B) not compile
C) understand the difference and run without problems
D) Compile, link, but not execute
E) None of the above
Answer: B
23) What is the value of cookies after the execution of the following statements?
A) 2
B) 0
C) 9
D) .5
E) None of these
Answer: A
24) This function in C++ allows you to identify how many bytes of storage on your computer system an
integer data value requires.
A) len
B) bytes
C) f(x)
D) int
E) sizeof
Answer: E
26) These are used to declare variables that can hold real numbers.
A) Integer data types
B) Real data types
C) Floating point data types
D) Long data types
E) None of the above
Answer: C
6
Copyright © 2015 Pearson Education, Inc.
27) The float data type is considered precision, and the double data type is considered
precision.
A) single, double
B) float, double
C) integer, double
D) short, long
E) None of the above
Answer: A
28) A variable whose value can be either true or false is of this data type.
A) binary
B) bool
C) T/F
D) float
E) None of the above
Answer: B
29) Which of the following correctly consolidates the following declaration statements into one
statement?
int x = 7;
int y = 16;
int z = 28;
30) A variable's is the part of the program that has access to the variable.
A) data type
B) value
C) scope
D) reach
E) None of the above
Answer: C
7
Copyright © 2015 Pearson Education, Inc.
32) This control sequence is used to skip over to the next horizontal tab stop.
A) \n
B) \h
C) \t
D) \a
E) \'
Answer: C
34) Look at the following program and answer the question that follows it.
8
Copyright © 2015 Pearson Education, Inc.
35) Which of the following defines a double-precision floating point variable named payCheck?
A) float payCheck;
B) double payCheck;
C) payCheck double;
D) Double payCheck;
Answer: B
A) Monday
Tuesday
Wednesday
C) MondayTuesdayWednesday
D) "Monday"
"Tuesday"
"Wednesday"
Answer: C
int number = 7;
A) The number is 7
B) The number is number
C) The number is7
D) The number is 0
Answer: B
9
Copyright © 2015 Pearson Education, Inc.
38) What will the following code display?
int x = 0, y = 1, z = 2;
A) 0 1 2
B) 0
1
2
C) xyz
D) 012
Answer: D
A) Four
score
and
seven
years ago
C) Four
score
and seven
years ago
D) Four score
and seven
years ago
Answer: A
10
Copyright © 2015 Pearson Education, Inc.
40) What will the following code display?
D) Four
score
and
seven
yearsago
Answer: C
A) Four
score
and
seven
years
ago
C) Fourscoreandsevenyearsago
D) Fourscore
andseven
yearsago
Answer: D
11
Copyright © 2015 Pearson Education, Inc.
42) Assume that a program has the following variable definition:
char letter;
Which of the following statements correctly assigns the character Z to the variable?
A) letter = Z;
B) letter = "Z";
C) letter = 'Z';
D) letter = (Z);
Answer: C
43) What will the value of x be after the following statements execute?
int x;
x = 18 / 4;
A) 4.5
B) 4
C) 0
D) unknown
Answer: B
44) What will the value of x be after the following statements execute?
int x;
x = 18.0 / 4;
A) 4.5
B) 4
C) 0
D) unknown
Answer: A
45) What will the value of x be after the following statements execute?
int x;
x = 18 % 4;
A) 0.45
B) 4
C) 2
D) unknown
Answer: C
12
Copyright © 2015 Pearson Education, Inc.
46) Assuming you are using a system with 1-byte characters, how many bytes of memory will the
following string literal occupy?
"William"
A) 7
B) 14
C) 8
D) 1
Answer: C
47) The first step in using the string class is to #include the header file.
A) iostream
B) cctype
C) cmath
D) string
E) None of the above
Answer: D
48) Assume that a program has the following string object definition:
string name;
Which of the following statements correctly assigns a string literal to the string object?
A) name = Jane;
B) name = "Jane";
C) name = 'Jane';
D) name = (Jane);
Answer: B
49) In C++ 11, if you want an integer literal to be treated as a long long int, you can append
at the end of the number.
A) L
B) <INT>
C) I
D) LL
E) None of the above
Answer: D
50) In C++ 11, the tells the compiler to determine the variable's data type from the initialization
value.
A) auto key word
B) #include preprocessor directive
C) variable's name
D) dynamic_cast key word
E) None of the above
Answer: A
13
Copyright © 2015 Pearson Education, Inc.
2.2 True/False Questions
1) True/False: When typing in your source code into the computer, you must be very careful since most
of your C++ instructions, header files, and variable names are case sensitive.
Answer: TRUE
3) True/False: The C++ language requires that you give variables names that indicate what the variables
are used for.
Answer: FALSE
4) True/False: A variable called "average" should be declared as an integer data type because it will
probably hold data that contains decimal places.
Answer: FALSE
7) True/False: C++ does not have a built in data type for storing strings of characters.
Answer: TRUE
8) True/False: If you do not follow a consistent programming style, your programs will generate
compiler errors.
Answer: FALSE
9) True/False: When writing long integer literals or long long integer literals in C++ 11, you can use either
an uppercase or lowercase L.
Answer: TRUE
10) True/False: C++ 11 introduces an alternative way to define variables, using the template key word
and an initialization value.
Answer: FALSE
14
Copyright © 2015 Pearson Education, Inc.