Name:
Class:
Date:
Page 1
Indicate whether the statement is true or false.
1. In C++, the float and double variable data types are used to store real numbers.
a.
True
b.
False
2. The name of a memory location in C++ can begin with a letter or a number.
a.
True
b.
False
3. The string data type is considered a primitive data type.
a.
True
b.
False
4. The binary number system uses the digits 0, 1, and 2 to represent all values.
a.
True
b.
False
5. A keyword is a word that has special meaning in the programming language you are using.
a.
True
b.
False
6. The value 29 is considered a double.
a.
True
b.
False
7. Camel case means capitalizing the entire name of a variable or named constant.
a.
True
b.
False
8. When naming a memory location in C++, names are not case sensitive.
a.
True
b.
False
9. The value of a named constant is allowed to change during runtime.
a.
True
b.
False
10. A variable is a memory location whose value can change during runtime.
a.
True
b.
False
Indicate the answer choice that best completes the statement or answers the question.
11. Which of the following is NOT a string literal constant?
a.
“”
b.
“&”
Name:
Class:
Date:
Page 2
c.
“Hello”
d.
‘abc’
12. What character is used to enclose a character literal constant?
a.
single quotes
b.
double quotes
c.
brackets
d.
parentheses
13. Which of the following is a word that has a special meaning in the programming language you are using?
a.
named constant
b.
keyword
c.
variable
d.
hashtag
14. What is a memory location whose value cannot change during runtime called?
a.
named constant
b.
keyword
c.
variable
d.
statement
15. What is the binary equivalent of the decimal number 7?
a.
1001
b.
0111
c.
0011
d.
1010
16. The short data type can store a number in the range from -32,768 to +32,767. How many bytes of memory is required
for the short data type?
a.
one
b.
two
c.
four
d.
eight
17. When declaring a named constant, which keyword indicates that the memory location being declared cannot be
changed during runtime?
a.
constant
b.
fixed
c.
const
d.
bool
18. What is the ASCII value of the ‘0’ character?
a.
0
b.
0.0
c.
66
d.
48
19. What is the result of raising the base number to the 0th power?
a.
0
b.
1
c.
the base number
d.
compiler error
20. Memory locations assigned the char data type can store how many characters?
a.
one
b.
zero
c.
more than one
d.
none of the above
21. What is an example of an invalid name for a memory location in C++?
a.
2ndname
b.
CiTy
c.
middle_name
d.
zip3Code
22. If the value’s data type does not match the memory location’s data type, what process does the computer use to
convert the value to fit the memory location?
Name:
Class:
Date:
Page 3
a.
truncation
b.
rounding
c.
implicit type conversion
d.
explicit type conversion
23. Which of the following is NOT a rule for naming a memory location in C++?
a.
the name must begin with a letter
b.
the name cannot contain spaces
c.
the name cannot be a keyword
d.
names in C++ are not case sensitive
24. Which data type is referred to as a user-defined data type?
a.
short
b.
char
c.
string
d.
bool
25. Which of the following would be a valid name for a memory location in C++?
a.
my.name
b.
3oreos
c.
a1B2c3D4
d.
me&you
26. When a value is converted from one data type to another data type that can store smaller numbers, what type of
conversion has occurred?
a.
demotion
b.
promotion
c.
compilation
d.
calculation
27. Which of the following is a valid integer value?
a.
5.132456e+03
b.
‘9’
c.
16.2
d.
-123
28. Which of the following data types can contain a real number?
a.
int
b.
float
c.
bool
d.
char
29. What is the term used for the assignment a beginning value to a memory location?
a.
implicit type conversion
b.
revision
c.
explicit type conversion
d.
initializing
30. What is the name of a coding scheme that assigns a specific numeric code to each character on your keyboard?
a.
Octal
b.
ASCII
c.
Hexadecimal
d.
Decimal
31. When a variable’s name contains two or more words, most C++ programmers enter the name using what type of
notation?
a.
all capital letters
b.
all lowercase letters
c.
a space between the words
d.
camel case
32. What is an item of data that can appear in a program instruction and can be stored in a memory location.
a.
variable
b.
named constant
c.
literal constant
d.
keyword
33. All numeric literal constants with a decimal place are considered which data type?
Name:
Class:
Date:
Page 4
a.
int
b.
double
c.
bool
d.
real
34. What is the decimal equivalent of the binary number 110?
a.
2
b.
4
c.
6
d.
8
35. Which of the following best describes a memory location whose value can change during runtime?
a.
named constant
b.
keyword
c.
variable
d.
statement
36. Which number system is used to store data in memory?
a.
decimal
b.
octal
c.
binary
d.
hexadecimal
37. What is the difference between fundamental data types and user-defined data types? Explain your answer.
38. Why is the use of camel case preferred in C++ programs when declaring variables and named constants that are
composed of two or more words? In addition to your explanation, give an example of where camel case is preferred.
39. Write the C++ statements to declare and approprately initialize variables representing the following:
1. Your name
2. Your age
3. Your income
40. The short data type requires two bytes of memory and stores an integer value in the range from -32,768 to
+32,767. Since the int data type requires four bytes of memory, why is the range for the int data type much more than
twice as much as that of the short data type? Be sure to show the math in your answer.
41. In the ASCII chart on page 59, notice that each of the binary values has eight bits, but the first bit is always 0. ASCII
does not use this bit in representing characters, but since bits are grouped in eights (a byte), this bit will always be
zero. Since only 7 bits are actually used in computing the maximum number of characters to represent, how many
characters are in the ASCII character set? Be sure to show the math in your answer.
42. Why is it important to always initialize variables when you declare them? Explain your answer.
43. What type of memory location is declared the most in C++ programs, variables or named constants? Explain your
answer.
44. What happens in C++ when a number is converted from one data type to another data type that can store only smaller
numbers? Are there any potential consequences from this occuring? If so, please give an example.
45. What is the primary difference between a variable and a named constant in C++?
Name:
Class:
Date:
Page 5
Name:
Class:
Date:
Name:
Class:
Date:
Page 7