Deck 2: Introduction to C++

Full screen (f)
exit full mode
Question
The expression 7 % 2 evaluates to

A)1
B)3.5
C)7.2
D)14
E)3
Use Space or
up arrow
down arrow
to flip the card.
Question
A _ variable can hold only one of two values: true or false.

A)single precision
B)T/F
C)binary
D)bool
E)char
Question
A C++ character constant (character literal)is enclosed in quotation marks, whereas a string constant (string literal)is enclosed in quotation marks.

A)open, closed
B)triple, double
C)double, single
D)no, some
E)single, double
Question
A _ is used to mark the end of a complete C++ programming statement.

A)closing brace
B)new line
C)period
D)semicolon
E)comment
Question
The is used to display information on the computer's screen.

A)output object
B)cout object
C)< symbol
D)print object
E)cin object
Question
Which of the following is/are valid C++ identifiers?

A)June.2010
B)June-2010
C)June_2010
D)2010June
E)Both C and D are valid identifiers, but A and B are not.
Question
C++ automatically places at the end of a string constant (string literal).

A)quotation marks
B)a semicolon
C)a newline escape sequence
D)a blank
E)the null terminator
Question
The numeric data types in C++ are broken into two categories:

A)integer and floating- point.
B)long and short.
C)real and unreal.
D)numbers and characters.
E)singles and doubles.
Question
What literal(s)appear in the following C++ statement? int number = 4 + 8;

A)12
B)4
C)8
D)number
E)both B and C
Question
Which of the following will cause the next output to begin on a new line?

A)cout << "/n";
B)cout << "endl";
C)cout << endl;
D)all of the above
E)A and C, but not B
Question
Which of the following will cause the next output to begin on a new line?

A)cout << endl;
B)cout << "endl";
C)cout << "/n";
D)all of the above
E)A and C, but not B
Question
A variable must be defined

A)and initialized at the same time.
B)in every program.
C)in order to perform output.
D)before it can be used.
E)in all of the above cases.
Question
The expression 5 / 2 evaluates to

A)1
B)2
C)2.5
D)5.2
E)10
Question
Every C++ program must have

A)variables.
B)literals.
C)comments.
D)a function called main..
E)all of the above.
Question
data types are used to define variables that can hold real numbers.

A)Floating- point
B)Real
C)String
D)Integer
E)Long
Question
What value will be assigned to the variable number by the following statement? <strong>What value will be assigned to the variable number by the following statement?   A)7</strong> A)8 B)<sup>7.8</sup> B)None of the above. C)It's unpredictable. That's the problem. <div style=padding-top: 35px>
A)7

A)8
B)7.8
B)None of the above.
C)It's unpredictable. That's the problem.
Question
Which of the following keywords is/are the names of C++ data types?

A)double
B)long
C)short
D)bool
E)All of the above
Question
What value will be assigned to the variable number by the following statement? int number = 3.75;
A)4

A)None of the above.
B)3
B)It's unpredictable. That's the problem.
C)3.75
Question
In programming terms, a group of characters inside a set of double quotation marks (" ")is called

A)a character literal.
B)a string constant.
C)a string literal.
D)all of the above.
E)either B or C, but not A.
Question
#include is an example of a(n)

A)comment.
B)compiler option.
C)preprocessor directive.
D)I/O statement.
E)stream directive.
Question
The following is a legal C++ statement to define and initialize a variable.
char firstName = "Jack";
Question
The bool data type

A)has only two values: true and false.
B)can be used to store a single character.
C)is used to store extra large numbers.
D)is used to represent numbers in E notation.
E)does none of the above.
Question
Which of the following is/are valid C++ identifiers?

A)department_9
B)aVeryLongVariableName
C)last-name
D)All of the above are valid identifiers.
E)Both A and B are valid identifiers, but C is not.
Question
C++ is a case- sensitive language.
Question
A variable of the char data type can hold a set of characters like "January".
Question
The following two C++ statements perform the same operation.
regWages = regPay + overTime; regPay + overTime = regWages;
Question
The following statements both declare the variable num to be an integer.
int num; INT num;
Question
In a C++ program, two slash marks ( // )indicate the beginning of

A)a program.
B)a comment.
C)a variable definition.
D)a block of code.
E)none of the above.
Question
You must have a(n)for every variable you include in a program.

A)numeric value
B)output statement
C)comment
D)purpose
E)definition
Question
An escape sequence must start with a forward slash (/).
Question
Variables represent storage locations in the computer's memory.
Question
must be included in a program in order to use the cout object.

A)Strings
B)A cout declaration
C)Opening and closing braces
D)The iostream header file
E)None of the above
Question
If number has been defined as an int variable, both of the following statements will print out its value:
cout << number; cout << "number";
Question
An operation that copies a value into a variable is called a(n)operation.

A)copy
B)cout
C)assignment
D)equals
E)declaration
Question
The directive causes the contents of another file to be inserted into a program.

A)#getfile
B)#insert
C)#library
D)#include
E)none of the above
Question
are data items whose values cannot change while the program is running.

A)Literals
B)Variables
C)Integers
D)Fixed data
E)None of the above
Question
The following two statements could be used interchangeably in a C++ program.
// Program Payroll
/* Program Payroll */
Question
The expression 5 % 2 evaluates to

A)1
B)2
C)2.5
D)5.2
E)10
Question
The expression 7 / 2 evaluates to

A)7.2
B)14
C)1
D)3.5
E)3
Question
The following two statements both assign the value 5 to the variable dept.
5 = dept; dept = 5;
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/40
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 2: Introduction to C++
1
The expression 7 % 2 evaluates to

A)1
B)3.5
C)7.2
D)14
E)3
A
2
A _ variable can hold only one of two values: true or false.

A)single precision
B)T/F
C)binary
D)bool
E)char
D
3
A C++ character constant (character literal)is enclosed in quotation marks, whereas a string constant (string literal)is enclosed in quotation marks.

A)open, closed
B)triple, double
C)double, single
D)no, some
E)single, double
E
4
A _ is used to mark the end of a complete C++ programming statement.

A)closing brace
B)new line
C)period
D)semicolon
E)comment
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
5
The is used to display information on the computer's screen.

A)output object
B)cout object
C)< symbol
D)print object
E)cin object
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
6
Which of the following is/are valid C++ identifiers?

A)June.2010
B)June-2010
C)June_2010
D)2010June
E)Both C and D are valid identifiers, but A and B are not.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
7
C++ automatically places at the end of a string constant (string literal).

A)quotation marks
B)a semicolon
C)a newline escape sequence
D)a blank
E)the null terminator
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
8
The numeric data types in C++ are broken into two categories:

A)integer and floating- point.
B)long and short.
C)real and unreal.
D)numbers and characters.
E)singles and doubles.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
9
What literal(s)appear in the following C++ statement? int number = 4 + 8;

A)12
B)4
C)8
D)number
E)both B and C
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
10
Which of the following will cause the next output to begin on a new line?

A)cout << "/n";
B)cout << "endl";
C)cout << endl;
D)all of the above
E)A and C, but not B
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
11
Which of the following will cause the next output to begin on a new line?

A)cout << endl;
B)cout << "endl";
C)cout << "/n";
D)all of the above
E)A and C, but not B
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
12
A variable must be defined

A)and initialized at the same time.
B)in every program.
C)in order to perform output.
D)before it can be used.
E)in all of the above cases.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
13
The expression 5 / 2 evaluates to

A)1
B)2
C)2.5
D)5.2
E)10
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
14
Every C++ program must have

A)variables.
B)literals.
C)comments.
D)a function called main..
E)all of the above.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
15
data types are used to define variables that can hold real numbers.

A)Floating- point
B)Real
C)String
D)Integer
E)Long
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
16
What value will be assigned to the variable number by the following statement? <strong>What value will be assigned to the variable number by the following statement?   A)7</strong> A)8 B)<sup>7.8</sup> B)None of the above. C)It's unpredictable. That's the problem.
A)7

A)8
B)7.8
B)None of the above.
C)It's unpredictable. That's the problem.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
17
Which of the following keywords is/are the names of C++ data types?

A)double
B)long
C)short
D)bool
E)All of the above
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
18
What value will be assigned to the variable number by the following statement? int number = 3.75;
A)4

A)None of the above.
B)3
B)It's unpredictable. That's the problem.
C)3.75
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
19
In programming terms, a group of characters inside a set of double quotation marks (" ")is called

A)a character literal.
B)a string constant.
C)a string literal.
D)all of the above.
E)either B or C, but not A.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
20
#include is an example of a(n)

A)comment.
B)compiler option.
C)preprocessor directive.
D)I/O statement.
E)stream directive.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
21
The following is a legal C++ statement to define and initialize a variable.
char firstName = "Jack";
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
22
The bool data type

A)has only two values: true and false.
B)can be used to store a single character.
C)is used to store extra large numbers.
D)is used to represent numbers in E notation.
E)does none of the above.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
23
Which of the following is/are valid C++ identifiers?

A)department_9
B)aVeryLongVariableName
C)last-name
D)All of the above are valid identifiers.
E)Both A and B are valid identifiers, but C is not.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
24
C++ is a case- sensitive language.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
25
A variable of the char data type can hold a set of characters like "January".
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
26
The following two C++ statements perform the same operation.
regWages = regPay + overTime; regPay + overTime = regWages;
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
27
The following statements both declare the variable num to be an integer.
int num; INT num;
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
28
In a C++ program, two slash marks ( // )indicate the beginning of

A)a program.
B)a comment.
C)a variable definition.
D)a block of code.
E)none of the above.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
29
You must have a(n)for every variable you include in a program.

A)numeric value
B)output statement
C)comment
D)purpose
E)definition
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
30
An escape sequence must start with a forward slash (/).
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
31
Variables represent storage locations in the computer's memory.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
32
must be included in a program in order to use the cout object.

A)Strings
B)A cout declaration
C)Opening and closing braces
D)The iostream header file
E)None of the above
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
33
If number has been defined as an int variable, both of the following statements will print out its value:
cout << number; cout << "number";
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
34
An operation that copies a value into a variable is called a(n)operation.

A)copy
B)cout
C)assignment
D)equals
E)declaration
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
35
The directive causes the contents of another file to be inserted into a program.

A)#getfile
B)#insert
C)#library
D)#include
E)none of the above
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
36
are data items whose values cannot change while the program is running.

A)Literals
B)Variables
C)Integers
D)Fixed data
E)None of the above
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
37
The following two statements could be used interchangeably in a C++ program.
// Program Payroll
/* Program Payroll */
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
38
The expression 5 % 2 evaluates to

A)1
B)2
C)2.5
D)5.2
E)10
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
39
The expression 7 / 2 evaluates to

A)7.2
B)14
C)1
D)3.5
E)3
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
40
The following two statements both assign the value 5 to the variable dept.
5 = dept; dept = 5;
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 40 flashcards in this deck.