Quiz 2 Flashcards
A statement that starts with a # symbol is called a:
A) Comment
B) Function
*C) Preprocessor directive
D) Key word
E) None of the above
The ________ is/are used to display information on the computer’s screen.
A) Opening and closing braces
B) Opening and closing quotation marks
*C) cout object
D) Backslash
E) None of the above
The ________ causes the contents of another file to be inserted into a program.
A) Backslash
B) Forwardslash
C) Semicolon
*D) #include directive
E) None of the above
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
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
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
Which data type typically requires only one byte of storage?
A) short
B) int
C) float
*D) char
E) double
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
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
Which character signifies the beginning of an escape sequence?
A) //
B) /
*C) \
D) #
E) {
________ 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
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
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
Which of the following correctly consolidates the following declaration statements into one statement?
int x = 7; int y = 16; int z = 28;
A) int x = 7; y = 16; z = 28;
B) int x = 7 y = 16 z = 28;
C) int x, y, z = 7, 16, 28
*D) int x = 7, y = 16, z = 28;
E) None of these will work.
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
Every complete C++ program must have a ________.
A) comment
*B) function named main
C) preprocessor directive
D) symbolic constant
E) cout statement
Which one of the following would be an illegal variable name?
A) dayOfWeek
*B) 3dGraph
C) _employee_num
D) June1997
E) itemsorderedforthemonth
What will the following code display?
cout << "Monday"; cout << "Tuesday"; cout << "Wednesday";
A) Monday
Tuesday
Wednesday
B) Monday Tuesday Wednesday
*C) MondayTuesdayWednesday
D) “Monday”
“Tuesday”
“Wednesday”
What will the following code display?
int number = 7; cout << "The number is " << "number" << endl;
A) The number is 7
*B) The number is number
C) The number is7
D) The number is 0
What will the following code display?
int x = 0, y = 1, z = 2; cout << x << y << z << endl;
A) 0 1 2
B) 0
1 2
C) xyz
*D) 012
What will the following code display?
cout << "Four\n" << "score\n"; cout << "and" << "\nseven"; cout << "\nyears" << " ago" << endl;
*A) Four
score
and
seven
years ago
B) Four score and seven
years ago
C) Four
score
and seven
years ago
D) Four score
and seven
years ago
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);
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
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
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