Deck 5: Understanding Arrays, Strings and Pointers

Full screen (f)
exit full mode
Question
Which of the following statements has an error?

A) int rent[4] = {250, 375, 460, 600};
B) int rent[] = {250, 375, 460, 600};
C) int rent[4] = {250, 375};
D) int rent[4] = {250, 375, 460, 600, 650};
Use Space or
up arrow
down arrow
to flip the card.
Question
A C++ value expressed within double quotation marks is commonly called a ____.

A) string
B) character
C) quote
D) citation
Question
Flag variables are usually bool type or ____ type.

A) char
B) int
C) float
D) double
Question
C++ programmers do not refer to an array of characters as a string unless the last usable character in the string is the null character.
Question
An alternative to parallel arrays is to create ____.

A) one-dimensional arrays
B) two-dimensional arrays
C) arrays of structure objects
D) arrays of flag variables
Question
A convenient way to set all array elements to zero is to declare as follows: int rent[20] = ____; .

A) 0
B) {0..0}
C) {0}
D) {}
Question
You can determine the size of variables in your system with the ____ operator.

A) size()
B) sizeof()
C) length()
D) len()
Question
Which of the following statements produces the same output as cout ? Assume someNumbers is an array of integers.
Question
When you assign one pointer to another, you are not making a copy of the data; instead, you are setting two pointers to point to the same memory location.
Question
Which of the following statements produces the same output as cout ? Assume someNumbers is an array of integers.
Question
Complete the following program, which displays all the values in the array:
Const int SZ_OF_ARRAY = 5;
Int arrayInt[SZ_OF_ARRAY] = {34, 56, 12, 3, 99};
For(int x = 0; ____ ; ++x)
Cout
Question
Suppose you create a structure that has an integer field called partNum ; Next, you create an array of ten elements of objects of this structure. Which of the following is a correct way to access the first element of the array?

A) (part.partNum)[0]
B) part.partNum[0]
C) part.[0]partNum
D) part[0].partNum
Question
You can use a variable to declare the size of an array.
Question
____ arrays are corresponding arrays in which values in the same relative locations are logically related.

A) Two-dimensional
B) Parallel
C) One-dimensional
D) Structured
Question
In C++, the first element in any array is the element with the 1 subscript.
Question
____ is a string constant.

A) 'H'
B) '\n'
C) "Hello"
D) Hello
Question
If you create a firstName string and initialize it to "Mary" , and then use the C++ statement cout , the output is ____.

A) Mary
B) ary
C) an error
D) empty because the program does not compile
Question
You can use the address operator (____) to examine the memory address of a variable.

A) %
B) $
C) *
D) &
Question
An array subscript must always be an integer.
Question
In C++, you are required to assign array values to elements in sequential order.
Question
Can you provide values for an array when you declare it? If so, how?
Question
What problem can you identify in the following program?
Char name1[] = "Mary";
Char name2[] = "Diane";
Strcpy(name2, "Margaret Veronica");

A) It tries to input a string value including whitespace.
B) It tries to assign one string to another using the assignment operator.
C) It tries to compare strings using the comparison operator.
D) It exceeds the bounds of an array.
Question
The ____ function reads characters into an array, up to a size limit or until the newline character is encountered, whichever comes first.

A) getche()
B) strcpy()
C) getline()
D) getch()
Question
When you declare an array, the size must be a(n) ____________________.
Question
To compare the contents of two strings you can use the ____.

A) compare() function
B) strcmp() function
C) strcpy() function
D) == operator
Question
Write a C++ statement that prints how much memory an integer uses.
Question
In C++, it is conventional to begin class names with a(n) ____________________ letter.
Question
When should you use an array instead of regular variables?
Question
____________________ are variables that can hold memory addresses.
Question
What happens if a subscript exceeds the size of an array?
Question
How does the hexadecimal numbering system work?
Question
Depending on your compiler, you might have to use the statement ____ at the top of your file to use the strcpy() function.

A) #include
B) #include
C) #include
D) #include
Question
A string ____________________ is a value within double quotes.
Question
To indicate that a variable is a pointer, you should begin the variable's name with a(n) ____.

A) asterisk
B) ampersand
C) pipe
D) exclamation point
Question
int , char , double , and float are primitive or ____________________ data types.
Question
Memory locations beyond an array are ____________________ for the array.
Question
The input ____ is a holding area for waiting input.

A) stack
B) queue
C) memory
D) buffer
Question
How do you declare an array in C++?
Question
To compare the contents of two string objects you can use the ____.

A) compare() function
B) strcmp() function
C) strcpy() function
D) == operator
Question
An array name actually represents a(n) ____________________.
Question
Identify and describe two common errors that are easy to make when manipulating arrays.
Question
Describe the various ways to place an asterisk when declaring an integer pointer.
Question
Match between columns
occurs when a pointer is left pointing to garbage
dangling reference
occurs when a pointer is left pointing to garbage
hexadecimal
occurs when a pointer is left pointing to garbage
one-dimensional array
occurs when a pointer is left pointing to garbage
memory address
occurs when a pointer is left pointing to garbage
element
occurs when a pointer is left pointing to garbage
two-dimensional array
occurs when a pointer is left pointing to garbage
array
occurs when a pointer is left pointing to garbage
subscript
occurs when a pointer is left pointing to garbage
flag variable
Question
Match between columns
array whose elements are accessed using two subscripts
dangling reference
array whose elements are accessed using two subscripts
hexadecimal
array whose elements are accessed using two subscripts
one-dimensional array
array whose elements are accessed using two subscripts
memory address
array whose elements are accessed using two subscripts
element
array whose elements are accessed using two subscripts
two-dimensional array
array whose elements are accessed using two subscripts
array
array whose elements are accessed using two subscripts
subscript
array whose elements are accessed using two subscripts
flag variable
Question
Match between columns
array whose elements are accessed using a single subscript
dangling reference
array whose elements are accessed using a single subscript
hexadecimal
array whose elements are accessed using a single subscript
one-dimensional array
array whose elements are accessed using a single subscript
memory address
array whose elements are accessed using a single subscript
element
array whose elements are accessed using a single subscript
two-dimensional array
array whose elements are accessed using a single subscript
array
array whose elements are accessed using a single subscript
subscript
array whose elements are accessed using a single subscript
flag variable
Question
Match between columns
you use it to mark an occurrence
dangling reference
you use it to mark an occurrence
hexadecimal
you use it to mark an occurrence
one-dimensional array
you use it to mark an occurrence
memory address
you use it to mark an occurrence
element
you use it to mark an occurrence
two-dimensional array
you use it to mark an occurrence
array
you use it to mark an occurrence
subscript
you use it to mark an occurrence
flag variable
Question
How can you copy the contents of one C-style string to another string in C++?
Question
Match between columns
single object in an array
dangling reference
single object in an array
hexadecimal
single object in an array
one-dimensional array
single object in an array
memory address
single object in an array
element
single object in an array
two-dimensional array
single object in an array
array
single object in an array
subscript
single object in an array
flag variable
Question
Match between columns
number that indicates the position of the particular array element being used
dangling reference
number that indicates the position of the particular array element being used
hexadecimal
number that indicates the position of the particular array element being used
one-dimensional array
number that indicates the position of the particular array element being used
memory address
number that indicates the position of the particular array element being used
element
number that indicates the position of the particular array element being used
two-dimensional array
number that indicates the position of the particular array element being used
array
number that indicates the position of the particular array element being used
subscript
number that indicates the position of the particular array element being used
flag variable
Question
How can you create a string variable in C++?
Question
Is there ever a circumstance when you can type two characters within single quotation marks? Explain.
Question
How is the null character represented in C++?
Question
Match between columns
list of individual items that all have the same type
dangling reference
list of individual items that all have the same type
hexadecimal
list of individual items that all have the same type
one-dimensional array
list of individual items that all have the same type
memory address
list of individual items that all have the same type
element
list of individual items that all have the same type
two-dimensional array
list of individual items that all have the same type
array
list of individual items that all have the same type
subscript
list of individual items that all have the same type
flag variable
Question
Match between columns
base 16 numbering system
dangling reference
base 16 numbering system
hexadecimal
base 16 numbering system
one-dimensional array
base 16 numbering system
memory address
base 16 numbering system
element
base 16 numbering system
two-dimensional array
base 16 numbering system
array
base 16 numbering system
subscript
base 16 numbering system
flag variable
Question
Match between columns
identifies each location where a piece of data can be stored
dangling reference
identifies each location where a piece of data can be stored
hexadecimal
identifies each location where a piece of data can be stored
one-dimensional array
identifies each location where a piece of data can be stored
memory address
identifies each location where a piece of data can be stored
element
identifies each location where a piece of data can be stored
two-dimensional array
identifies each location where a piece of data can be stored
array
identifies each location where a piece of data can be stored
subscript
identifies each location where a piece of data can be stored
flag variable
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/55
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 5: Understanding Arrays, Strings and Pointers
1
Which of the following statements has an error?

A) int rent[4] = {250, 375, 460, 600};
B) int rent[] = {250, 375, 460, 600};
C) int rent[4] = {250, 375};
D) int rent[4] = {250, 375, 460, 600, 650};
D
2
A C++ value expressed within double quotation marks is commonly called a ____.

A) string
B) character
C) quote
D) citation
A
3
Flag variables are usually bool type or ____ type.

A) char
B) int
C) float
D) double
B
4
C++ programmers do not refer to an array of characters as a string unless the last usable character in the string is the null character.
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
5
An alternative to parallel arrays is to create ____.

A) one-dimensional arrays
B) two-dimensional arrays
C) arrays of structure objects
D) arrays of flag variables
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
6
A convenient way to set all array elements to zero is to declare as follows: int rent[20] = ____; .

A) 0
B) {0..0}
C) {0}
D) {}
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
7
You can determine the size of variables in your system with the ____ operator.

A) size()
B) sizeof()
C) length()
D) len()
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
8
Which of the following statements produces the same output as cout ? Assume someNumbers is an array of integers.
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
9
When you assign one pointer to another, you are not making a copy of the data; instead, you are setting two pointers to point to the same memory location.
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
10
Which of the following statements produces the same output as cout ? Assume someNumbers is an array of integers.
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
11
Complete the following program, which displays all the values in the array:
Const int SZ_OF_ARRAY = 5;
Int arrayInt[SZ_OF_ARRAY] = {34, 56, 12, 3, 99};
For(int x = 0; ____ ; ++x)
Cout
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
12
Suppose you create a structure that has an integer field called partNum ; Next, you create an array of ten elements of objects of this structure. Which of the following is a correct way to access the first element of the array?

A) (part.partNum)[0]
B) part.partNum[0]
C) part.[0]partNum
D) part[0].partNum
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
13
You can use a variable to declare the size of an array.
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
14
____ arrays are corresponding arrays in which values in the same relative locations are logically related.

A) Two-dimensional
B) Parallel
C) One-dimensional
D) Structured
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
15
In C++, the first element in any array is the element with the 1 subscript.
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
16
____ is a string constant.

A) 'H'
B) '\n'
C) "Hello"
D) Hello
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
17
If you create a firstName string and initialize it to "Mary" , and then use the C++ statement cout , the output is ____.

A) Mary
B) ary
C) an error
D) empty because the program does not compile
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
18
You can use the address operator (____) to examine the memory address of a variable.

A) %
B) $
C) *
D) &
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
19
An array subscript must always be an integer.
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
20
In C++, you are required to assign array values to elements in sequential order.
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
21
Can you provide values for an array when you declare it? If so, how?
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
22
What problem can you identify in the following program?
Char name1[] = "Mary";
Char name2[] = "Diane";
Strcpy(name2, "Margaret Veronica");

A) It tries to input a string value including whitespace.
B) It tries to assign one string to another using the assignment operator.
C) It tries to compare strings using the comparison operator.
D) It exceeds the bounds of an array.
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
23
The ____ function reads characters into an array, up to a size limit or until the newline character is encountered, whichever comes first.

A) getche()
B) strcpy()
C) getline()
D) getch()
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
24
When you declare an array, the size must be a(n) ____________________.
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
25
To compare the contents of two strings you can use the ____.

A) compare() function
B) strcmp() function
C) strcpy() function
D) == operator
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
26
Write a C++ statement that prints how much memory an integer uses.
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
27
In C++, it is conventional to begin class names with a(n) ____________________ letter.
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
28
When should you use an array instead of regular variables?
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
29
____________________ are variables that can hold memory addresses.
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
30
What happens if a subscript exceeds the size of an array?
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
31
How does the hexadecimal numbering system work?
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
32
Depending on your compiler, you might have to use the statement ____ at the top of your file to use the strcpy() function.

A) #include
B) #include
C) #include
D) #include
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
33
A string ____________________ is a value within double quotes.
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
34
To indicate that a variable is a pointer, you should begin the variable's name with a(n) ____.

A) asterisk
B) ampersand
C) pipe
D) exclamation point
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
35
int , char , double , and float are primitive or ____________________ data types.
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
36
Memory locations beyond an array are ____________________ for the array.
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
37
The input ____ is a holding area for waiting input.

A) stack
B) queue
C) memory
D) buffer
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
38
How do you declare an array in C++?
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
39
To compare the contents of two string objects you can use the ____.

A) compare() function
B) strcmp() function
C) strcpy() function
D) == operator
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
40
An array name actually represents a(n) ____________________.
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
41
Identify and describe two common errors that are easy to make when manipulating arrays.
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
42
Describe the various ways to place an asterisk when declaring an integer pointer.
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
43
Match between columns
occurs when a pointer is left pointing to garbage
dangling reference
occurs when a pointer is left pointing to garbage
hexadecimal
occurs when a pointer is left pointing to garbage
one-dimensional array
occurs when a pointer is left pointing to garbage
memory address
occurs when a pointer is left pointing to garbage
element
occurs when a pointer is left pointing to garbage
two-dimensional array
occurs when a pointer is left pointing to garbage
array
occurs when a pointer is left pointing to garbage
subscript
occurs when a pointer is left pointing to garbage
flag variable
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
44
Match between columns
array whose elements are accessed using two subscripts
dangling reference
array whose elements are accessed using two subscripts
hexadecimal
array whose elements are accessed using two subscripts
one-dimensional array
array whose elements are accessed using two subscripts
memory address
array whose elements are accessed using two subscripts
element
array whose elements are accessed using two subscripts
two-dimensional array
array whose elements are accessed using two subscripts
array
array whose elements are accessed using two subscripts
subscript
array whose elements are accessed using two subscripts
flag variable
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
45
Match between columns
array whose elements are accessed using a single subscript
dangling reference
array whose elements are accessed using a single subscript
hexadecimal
array whose elements are accessed using a single subscript
one-dimensional array
array whose elements are accessed using a single subscript
memory address
array whose elements are accessed using a single subscript
element
array whose elements are accessed using a single subscript
two-dimensional array
array whose elements are accessed using a single subscript
array
array whose elements are accessed using a single subscript
subscript
array whose elements are accessed using a single subscript
flag variable
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
46
Match between columns
you use it to mark an occurrence
dangling reference
you use it to mark an occurrence
hexadecimal
you use it to mark an occurrence
one-dimensional array
you use it to mark an occurrence
memory address
you use it to mark an occurrence
element
you use it to mark an occurrence
two-dimensional array
you use it to mark an occurrence
array
you use it to mark an occurrence
subscript
you use it to mark an occurrence
flag variable
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
47
How can you copy the contents of one C-style string to another string in C++?
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
48
Match between columns
single object in an array
dangling reference
single object in an array
hexadecimal
single object in an array
one-dimensional array
single object in an array
memory address
single object in an array
element
single object in an array
two-dimensional array
single object in an array
array
single object in an array
subscript
single object in an array
flag variable
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
49
Match between columns
number that indicates the position of the particular array element being used
dangling reference
number that indicates the position of the particular array element being used
hexadecimal
number that indicates the position of the particular array element being used
one-dimensional array
number that indicates the position of the particular array element being used
memory address
number that indicates the position of the particular array element being used
element
number that indicates the position of the particular array element being used
two-dimensional array
number that indicates the position of the particular array element being used
array
number that indicates the position of the particular array element being used
subscript
number that indicates the position of the particular array element being used
flag variable
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
50
How can you create a string variable in C++?
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
51
Is there ever a circumstance when you can type two characters within single quotation marks? Explain.
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
52
How is the null character represented in C++?
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
53
Match between columns
list of individual items that all have the same type
dangling reference
list of individual items that all have the same type
hexadecimal
list of individual items that all have the same type
one-dimensional array
list of individual items that all have the same type
memory address
list of individual items that all have the same type
element
list of individual items that all have the same type
two-dimensional array
list of individual items that all have the same type
array
list of individual items that all have the same type
subscript
list of individual items that all have the same type
flag variable
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
54
Match between columns
base 16 numbering system
dangling reference
base 16 numbering system
hexadecimal
base 16 numbering system
one-dimensional array
base 16 numbering system
memory address
base 16 numbering system
element
base 16 numbering system
two-dimensional array
base 16 numbering system
array
base 16 numbering system
subscript
base 16 numbering system
flag variable
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
55
Match between columns
identifies each location where a piece of data can be stored
dangling reference
identifies each location where a piece of data can be stored
hexadecimal
identifies each location where a piece of data can be stored
one-dimensional array
identifies each location where a piece of data can be stored
memory address
identifies each location where a piece of data can be stored
element
identifies each location where a piece of data can be stored
two-dimensional array
identifies each location where a piece of data can be stored
array
identifies each location where a piece of data can be stored
subscript
identifies each location where a piece of data can be stored
flag variable
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 55 flashcards in this deck.