CPP
Every complete C++ program must have a _____________.
function named main
A character literal is enclosed in ________ quotation marks, whereas a string literal is enclosed in ________ quotation marks.
single, double
The float data type is considered _____ precision, and the double data type is considered _______ precision.
single, double
This function in C++ allows you to identify how many bytes of storage on your computer system an integer data value requires.
sizeof
The first step in using the string class is to #include the ___________ header file
string
The _____ causes the contents of another file to be inserted into a program.
#include directive
What is the modulus operator?
%
Character constants in C++ are always enclosed in ______.
'single quotation marks'
What is the output of the following statement? cout << 4 * (15 / (1 + 3)) << endl;
12
What will the value of x be after the following statements execute? int x; x = 18.0 / 4;
4.5
Assuming you are using a system with 1-byte characters, how many bytes of memory will the following string literal occupy? "William"
8
A variable called "average" should be declared as an integer data type because it will probably hold data that contains decimal places. (T/F)
F
If you do not follow a consistent programming style, your programs will generate compiler errors. (T/F)
F
The C++ language requires that you give variables names that indicate what the variables are used for. (T/F)
F
These are used to declare variables that can hold real numbers
Floating point data types
Besides decimal, two other number systems you might encounter in C++ programs are:
Hexadecimal and Octal
These are data items whose values do not change while the program is running
Literals
What will the following code display? cout << "Monday"; cout << "Tuesday"; cout << "Wednesday";
MondayTuesdayWednesday
In memory, C++ automatically places a ___________ at the end of string literals
Null terminator
A statement that starts with a # is called a:
Preprocessor directive
This is used to mark the end of a complete C++ programming statement.
Semicolon
In programming terms, a group of characters inside a set of quotation marks is called a:
String literal
C++ does not have a built in data type for storing strings of characters. (T/F)
T
Escape sequences are always stored internally as a single character. (T/F)
T
Floating point constants are normally stored in memory as doubles. (T/F)
T
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. (T/F)
T
In a C++ program, two slash marks ( // ) indicate:
The beginning of a comment
____________ must be included in any program that uses the cout object.
The header file iostream
_____________ represent storage locations in the computer's memory
Variables
Which character signifies the beginning of an escape sequence?
\
Which escape sequence causes the cursor to move to the beginning of the current line?
\r
This control sequence is used to skip over to the next horizontal tab stop.
\t
Which data type typically requires only one byte of storage?
char
The ______ is/are used to display information on the computer's screen.
cout object
What will the following code display? int x = 0, y = 1, z = 2; cout << x << y << z << endl; a. 0 1 2 c. xyz b. 0 1 2 c. xyz d. 012
d) 012
How would you consolidate 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
d) int x = 7, y = 16, z = 28;
Of the following, which is a valid C++ identifier? a) June1997 b)_employee_number c)___department d)myExtraLongVariableName e)All of the above are valid identifiers
e)All of the above are valid identifiers
Look at the following program and answer the question that follows it 1 // This program displays my gross wages. 2 // I worked 40 hours and I make $20.00 per hour. 3 #include <iostream> 4 using namespace std; 5 6 int main() 7 { 8 int hours; 9 double payRate, grossPay; 10 11 hours = 40; 12 payRate = 20.0; 13 grossPay = hours * payRate; 14 cout << "My gross pay is $" << grossPay << endl; 15 return 0; 16 } Which line(s) in this program cause output to be displayed on the screen?
14
In the C++ instruction, cookies = number % children; given the following declaration statement: int number = 38, children = 4, cookies;
2
What will the value of x be after the following statements execute? int x; x = 18 % 4;
2
Which one of the following would be an illegal variable name?
3dGraph
For every opening brace in a C++ program, there must be a
Closing brace
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
a. Four score and seven years ago
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
b) The number is number
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;
b) double payCheck;
What will the value of x be after the following statements execute? int x; x = 18 / 4;
b. 4
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);
b. name = "Jane";
A variable whose value can be either true or false is of this data type
bool
What will the following code display? cout << "Four " << "score "; cout << "and " << "seven/n"; cout << "years" << "ago" << endl; a. Four score and seven yearsago b. Four score and seven years ago c. Four score and seven/nyearsago d. Four score and seven y earsago
c. Four score and seven/nyearsago
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);
c. letter = 'Z';
What will the following code display? cout << "Four" << "score" << endl; cout << "and" << "seven" << endl; cout << "years" << "ago" << endl; a. Four score and seven years ago b. Four score and seven years ago c. Fourscoreandsevenyearsago d. Fourscore andseven yearsago
d. Fourscore andseven yearsago
You must have a ___________ for every variable you intend to use in a program
definition
The numeric data types in C++ can be broken into two general categories:
integer and floating point
If you use a C++ key word as an identifier, your program will:
not compile
A variable's ___________ is the part of the program that has access to the variable
scope
A preprocessor directive does not require a semicolon at the end. (T/F)
T