COSC 1436 Chapter 2 Quiz With
Complete Solutions
In a C++ program, two slash marks ( // ) indicate: - ANSWER The beginning of a
comment
A statement that starts with a # symbol is called a: - ANSWER Preprocessor
directive
For every opening brace in a C++ program, there must be a: - ANSWER Closing
brace
The ________ is/are used to display information on the computer's screen. -
ANSWER cout object
The ________ causes the contents of another file to be inserted into a program. -
ANSWER #include directive
________ represent storage locations in the computer's memory. - ANSWER
Variables
These are data items whose values do not change while the program is running.
- ANSWER Literals
You must have a ________ for every variable you intend to use in a program. -
ANSWER definition
Of the following, which is a valid C++ identifier? - ANSWER June1997
_employee_number
___department
myExtraLongVariableName
All of these are valid identifiers.
The numeric data types in C++ can be broken into two general categories: -
ANSWER integer and floating point
Besides decimal, two other number systems you might encounter in C++
programs are: - ANSWER Hexadecimal and Octal
A character literal is enclosed in ________ quotation marks, whereas a string
literal is enclosed in ________ quotation marks. - ANSWER single, double
, In memory, C++ automatically places a ________ at the end of string literals. -
ANSWER Null terminator
Which escape sequence causes the cursor to move to the beginning of the
current line? - ANSWER \r
What is the modulus operator? - ANSWER %
Which data type typically requires only one byte of storage? - ANSWER char
What is the output of the following statement?
cout << 4 * (15 / (1+3)) << endl;
Select one: - ANSWER 12
In programming terms, a group of characters inside a set of quotation marks is
called aNo: - ANSWER String literal
This is used to mark the end of a complete C++ programming statement. -
ANSWER Semicolon
Which character signifies the beginning of an escape sequence? - ANSWER \
________ must be included in any program that uses the cout object. - ANSWER
The header file iostream
If you use a C++ key word as an identifier, your program will: - ANSWER not
compile
What is the value of cookies after the execution of the following statements?
int number = 38, children = 4, cookies;
cookies = number % children; - ANSWER 2
This function in C++ allows you to identify how many bytes of storage on your
computer system an integer data value requires. - ANSWER sizeof
Character constants in C++ are always enclosed in ________. - ANSWER 'single
quotation marks'
These are used to declare variables that can hold real numbers. - ANSWER
Floating point data types
Complete Solutions
In a C++ program, two slash marks ( // ) indicate: - ANSWER The beginning of a
comment
A statement that starts with a # symbol is called a: - ANSWER Preprocessor
directive
For every opening brace in a C++ program, there must be a: - ANSWER Closing
brace
The ________ is/are used to display information on the computer's screen. -
ANSWER cout object
The ________ causes the contents of another file to be inserted into a program. -
ANSWER #include directive
________ represent storage locations in the computer's memory. - ANSWER
Variables
These are data items whose values do not change while the program is running.
- ANSWER Literals
You must have a ________ for every variable you intend to use in a program. -
ANSWER definition
Of the following, which is a valid C++ identifier? - ANSWER June1997
_employee_number
___department
myExtraLongVariableName
All of these are valid identifiers.
The numeric data types in C++ can be broken into two general categories: -
ANSWER integer and floating point
Besides decimal, two other number systems you might encounter in C++
programs are: - ANSWER Hexadecimal and Octal
A character literal is enclosed in ________ quotation marks, whereas a string
literal is enclosed in ________ quotation marks. - ANSWER single, double
, In memory, C++ automatically places a ________ at the end of string literals. -
ANSWER Null terminator
Which escape sequence causes the cursor to move to the beginning of the
current line? - ANSWER \r
What is the modulus operator? - ANSWER %
Which data type typically requires only one byte of storage? - ANSWER char
What is the output of the following statement?
cout << 4 * (15 / (1+3)) << endl;
Select one: - ANSWER 12
In programming terms, a group of characters inside a set of quotation marks is
called aNo: - ANSWER String literal
This is used to mark the end of a complete C++ programming statement. -
ANSWER Semicolon
Which character signifies the beginning of an escape sequence? - ANSWER \
________ must be included in any program that uses the cout object. - ANSWER
The header file iostream
If you use a C++ key word as an identifier, your program will: - ANSWER not
compile
What is the value of cookies after the execution of the following statements?
int number = 38, children = 4, cookies;
cookies = number % children; - ANSWER 2
This function in C++ allows you to identify how many bytes of storage on your
computer system an integer data value requires. - ANSWER sizeof
Character constants in C++ are always enclosed in ________. - ANSWER 'single
quotation marks'
These are used to declare variables that can hold real numbers. - ANSWER
Floating point data types