C++ Quiz 2

25 July 2022
4.7 (114 reviews)
40 test answers

Unlock all answers in this set

Unlock answers (36)
question
In a C++ program, two slash marks ( // ) indicate: Select one: a. The end of a statement b. The beginning of a comment c. The end of the program d. The beginning of a block of code e. None of these
answer
b. ( The beginning of a comment)
question
A statement that starts with a # symbol is called a: Select one: a. Comment b. Function c. Preprocessor directive d. Key word e. None of these
answer
c. (Preprocessor directive )
question
For every opening brace in a C++ program, there must be a: Select one: a. String literal b. Function c. Variable d. Closing brace e. None of these
answer
d. ( Closing brace)
question
The ________ is/are used to display information on the computer's screen. Select one: a. Opening and closing braces b. Opening and closing quotation marks c. cout object d. Backslash e. None of these
answer
c. (cout object )
question
The ________ causes the contents of another file to be inserted into a program. Select one: a. Backslash b. Pound sign c. Semicolon d. #include directive e. None of these
answer
d. (#include directive )
question
________ represent storage locations in the computer's memory. Select one: a. Literals b. Variables c. Comments d. Integers e. None of these
answer
b. (Variables )
question
These are data items whose values do not change while the program is running. Select one: a. Literals b. Variables c. Comments d. Integers e. None of these
answer
a. ( Literals)
question
You must have a ________ for every variable you intend to use in a program. Select one: a. purpose b. definition c. comment d. constant e. None of these
answer
b. (definition )
question
Of the following, which is a valid C++ identifier? Select one: a. June1997 b. _employee_number c. ___department d. myExtraLongVariableName e. All of these are valid identifiers.
answer
e. (All of these are valid identifiers.)
question
The numeric data types in C++ can be broken into two general categories: Select one: a. numbers and characters b. singles and doubles c. integer and floating point d. real and unreal e. None of these
answer
c.( integer and floating point )
question
Besides decimal, two other number systems you might encounter in C++ programs are: Select one: a. Octal and Fractal b. Hexadecimal and Octal c. Unary and Quaternary d. Base 7 and Base 9 e. None of these
answer
b. (Hexadecimal and Octal)
question
A character literal is enclosed in ________ quotation marks, whereas a string literal is enclosed in ________ quotation marks. Select one: a. double, single b. triple, double c. open, closed d. single, double e. None of these
answer
d. ( single, double )
question
In memory, C++ automatically places a ________ at the end of string literals. Select one: a. Semicolon b. Quotation marks c. Null terminator d. Newline escape sequence e. None of these
answer
c. (Null terminator )
question
Which escape sequence causes the cursor to move to the beginning of the current line? Select one: a. t b. a c. n d. b e. r
answer
e. (r)
question
What is the modulus operator? Select one: a. % b. + c. || d. & e. *
answer
a. (% )
question
Which data type typically requires only one byte of storage? Select one: a. double b. int c. char d. short e. float
answer
c. (char )
question
What is the output of the following statement? cout << 4 * ( 15 / (1+3 )) << endl; Select one: a. 15 b. 12 c. 63 d. 72 e. None of these
answer
b. (12)
question
In programming terms, a group of characters inside a set of quotation marks is called aNo: Select one: a. String literal b. Variable c. Operation d. Statement e. None of these
answer
a. (String literal )
question
This is used to mark the end of a complete C++ programming statement. Select one: a. Pound Sign b. Semicolon c. Data type d. Void e. None of these
answer
b. (Semicolon )
question
Which character signifies the beginning of an escape sequence? Select one: a. b. # c. { d. / e. //
answer
a. ()
question
________ must be included in any program that uses the cout object. Select one: a. Opening and closing braces b. The header file iostream c. Comments d. Escape sequences e. None of these
answer
b. (The header file iostream )
question
If you use a C++ key word as an identifier, your program will: Select one: 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 these
answer
b. (not compile)
question
What is the value of cookies after the execution of the following statements? int number= 38, children=4, cookies; cookies = number % children; Select one: a. 2 b. 0 c. 9 d. .5 e. None of these
answer
a. (2 )
question
This function in C++ allows you to identify how many bytes of storage on your computer system an integer data value requires. Select one: a. int b. sizeof c. bytes d. f(x) e. len
answer
b. (b. sizeof )
question
Character constants in C++ are always enclosed in ________. Select one: a. {braces} b. [brackets] c. "double quotation marks" d. 'single quotation marks' e. (parentheses)
answer
d. ('single quotation marks' )
question
These are used to declare variables that can hold real numbers. Select one: a. Integer data types b. Real data types c. Floating point data types d. Long data types e. None of these
answer
c. ( Floating point data types)
question
The float data type is considered ________ precision, and the double data type is considered ________ precision. Select one: a. single, double b. float, double c. integer, double d. short, long e. None of these
answer
a. (single, double )
question
A variable whose value can be either true or false is of this data type. Select one: a. binary b. bool c. T/F d. float e. None of these
answer
b. (bool )
question
Which of the following correctly consolidates the following declaration statements into one statement? Select one: a. int x, y, z= 7, 16, 28 b. None of these will work. c. int x=7, y=16, z=28; d. int x=7; y=7; z=28; e. int x= 7 y=4 z=4
answer
c. ( int x=7, y=16, z=28;)
question
A variable's ________ is the part of the program that has access to the variable. Select one: a. data type b. value Incorrect c. scope d. reach e. None of these
answer
c. (scope)
question
Every complete C++ program must have a ________. Select one: a. symbolic constant b. cout statement c. comment d. function named main e. preprocessor directive
answer
d.( function named main )
question
This control sequence is used to skip over to the next horizontal tab stop. Select one: a. n b. t c. a d. ' e. h
answer
b. (t)
question
Which one of the following would be an illegal variable name? Select one: a. _employee_num b. dayOfWeek c. 3dGraph d. June1997 e. itemsorderedforthemonth
answer
c. (3dGraph)
question
Which of the following defines a double-precision floating point variable named payCheck? Select one: a. payCheck double; b. Double payCheck; c. double payCheck; d. float payCheck;
answer
c. (double payCheck; )
question
What will the following code display? cout << "Monday"; cout << "Tuesday"; cout << "Wednesday"; Select one: a. MondayTuesdayWednesday b. Monday Tuesday Wednesday c. "Monday" "Tuesday" "Wednesday" d. Monday Tuesday Wednesday
answer
a. (MondayTuesdayWednesday)
question
What will the following code display? int number= 7; cout<< "The number is "<< "number" << endl; Select one: a. The number is number b. The number is 0 c. The number is7 d. The number is 7
answer
a. (The number is number)
question
Assuming you are using a system with 1-byte characters, how many bytes of memory will the following string literal occupy? "William" Select one: a. 8 b. 14 c. 7 d. 1
answer
a. (8)
question
The first step in using the string class is to #include the ________ header file. Select one: a. iostream b. cctype c. cmath d. string e. None of these
answer
d. (string)
question
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. Select one: a. L b. c. I d. LL e. None of these
answer
d. (LL)
question
In C++ 11, the ________ tells the compiler to determine the variable's data type from the initialization value. Select one: a. auto key word b. #include preprocessor directive c. variable's name d. dynamic_cast key word e. None of these
answer
a. (auto key word)