ch7 Flashcards

1
Q

7.1 De ne the following arrays:
A) empNums, a 100-element array of ints
B) payRates, a 25-element array of floats
C) miles, a 14-element array of longs
D) cityName, a 26-element array of string objects
E) lightYears, a 1,000-element array of doubles

A
7.1 A) int empNums[100];
B) float payRates[25];
C) long miles[14];
D) string cityNames[26];
E) double lightYears[1000];
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
7.2 What s wrong with the following array definitions?
int readings[-1];
float measurements[4.5];
int size;
string names[size];
A

7.2 int readings[-1]; // Size declarator cannot be negative
float measurements[4.5]; // Size declarator must be an integer
int size;
string names[size]; // Size declarator must be a constant

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

7.3 What would the valid subscript values be in a four-element array of doubles?

A

7.3 0 through 3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

7.4 What is the difference between an array s size declarator and a subscript?

A

7.4 The size declarator is used in the array declaration statement. It specifies the number of
elements in the array. A subscript is used to access an individual element in an array.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

7.5 What is array bounds checking ? Does C++ perform it?

A

7.5 Array bounds checking is a safeguard provided by some languages. It prevents a program
from using a subscript that is beyond the boundaries of an array. C++ does not perform
array bounds checking.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

7.6 What is the output of the following code?
int values[5], count;
for (count = 0; count

A
7.6 
1
2
3
4
5
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
7.7 The following program skeleton contains a 20-element array of ints called fish.
When completed, the program should ask how many sh were caught by shermen
1 through 20, and store this data in the array. Complete the program.
#include 
using namespace std;
int main()
{
const int NUM_FISH = 20;
int fish[NUM_FISH];
// You must finish this program. It should ask how
// many fish were caught by fishermen 1-20, and
// store this data in the array fish.
return 0;
}
A
7.7 #include 
using namespace std;
int main()
{
const int NUM_FISH = 20;
int fish[NUM_FISH], count;
cout > fish[count];
}
return 0;
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

7.8 De ne the following arrays:
A) ages, a 10-element array of ints initialized with the values 5, 7, 9, 14, 15,
17, 18, 19, 21, and 23.
B) temps, a 7-element array of floats initialized with the values 14.7, 16.3,
18.43, 21.09, 17.9, 18.76, and 26.7.
C) alpha, an 8-element array of chars initialized with the values J , B , L, A,
* , $ , H , and M .

A

7.8 A) int ages[10] = {5, 7, 9, 14, 15, 17, 18, 19, 21, 23};
B) float temps[7] = {14.7, 16.3, 18.43, 21.09, 17.9, 18.76, 26.7};
C) char alpha[8] = {‘J’, ‘B’, ‘L’, ‘A’, ‘*’, ‘$’, ‘H’, ‘M’};

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

7.9 Is each of the following a valid or invalid array definition? (If a definition is
invalid, explain why.)
int numbers[10] = {0, 0, 1, 0, 0, 1, 0, 0, 1, 1};
int matrix[5] = {1, 2, 3, 4, 5, 6, 7};
double radii[10] = {3.2, 4.7};
int table[7] = {2, , , 27, , 45, 39};
char codes[] = {‘A’, ‘X’, ‘1’, ‘2’, ‘s’};
int blanks[];

A

7.9 The definition of numbers is valid.
The declaration of matrix is invalid because there are too many values in the initialization list.
The definition of radii is valid.
The definition of table is invalid. Values cannot be skipped in the initialization list.
The definition of codes is valid.
The definition of blanks is invalid. An initialization list must be provided when an array
is implicitly sized.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

7.10 Given the following array definition:
int values[] = {2, 6, 10, 14};
What does each of the following display?
A) cout

A

7.10 A) 0
B) 3
C) 6
D) 14

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

7.11 Given the following array definition:
int nums[5] = {1, 2, 3};
What will the following statement display?
cout &laquo_space;nums[3];

A

7.11 0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

7.12 What is the output of the following code? (You may need to use a calculator.)
double balance[5] = {100.0, 250.0, 325.0, 500.0, 1100.0};
const double INTRATE = 0.1;
cout

A
  1. 12
  2. 00
  3. 00
  4. 50
  5. 00
  6. 00
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q
7.13 What is the output of the following code? (You may need to use a calculator.)
const int SIZE = 5;
int time[SIZE] = {1, 2, 3, 4, 5},
speed[SIZE] = {18, 4, 27, 52, 100},
dist[SIZE];
for (int count = 0; count
A
7.13 
1 18 18
2 4 8
3 27 81
4 52 208
5 100 500
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

7.14 Given the following array definitions
double array1[4] = {1.2, 3.2, 4.2, 5.2};
double array2[4];
will the following statement work? If not, why?
array2 = array1;

A

7.14 No. An entire array cannot be copied in a single statement with the = operator. The array
must be copied element-by-element.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

7.15 When an array name is passed to a function, what is actually being passed?

A

7.15 The address of the array.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

7.16 When used as function arguments, are arrays passed by value?

A

7.16 No.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q
7.17 What is the output of the following program? (You may need to consult the
ASCII table in Appendix B.)
#include 
using namespace std;
// Function prototypes
void fillArray(char [], int);
void showArray(const char [], int);
int main ()
{
const int SIZE = 8;
char prodCode[SIZE] = {'0', '0', '0', '0', '0', '0', '0', '0'};
fillArray(prodCode, SIZE);
showArray(prodCode, SIZE);
return 0;
}
// Definition of function fillArray.
// (Hint: 65 is the ASCII code for 'A')
void fillArray(char arr[], int size)
{
char code = 65;
for (int k = 0; k
A

7.17 ABCDEFGH

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q
7.18 The following program skeleton, when completed, will ask the user to enter 10
integers, which are stored in an array. The function avgArray, which you must
write, is to calculate and return the average of the numbers entered.
#include 
using namespace std;
// Write your function prototype here
int main()
{
const int SIZE = 10;
int userNums[SIZE];
cout > userNums[count];
}
cout
A
7.18 (The entire program is shown here.)
#include 
using namespace std;
// Function prototype here
double avgArray(int []);
int main()
{
const int SIZE = 10;
int userNums[SIZE];
cout > userNums[count];
}
cout
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

7.19 Define a two-dimensional array of ints named grades. It should have 30 rows
and 10 columns.

A

7.19 int grades[30][10];

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

7.20 How many elements are in the following array?

double sales[6][4];

A

7.20 24

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

7.21 Write a statement that assigns the value 56893.12 to the first column of the first
row of the array defined in Question 7.20.

A

7.21 sales[0][0] = 56893.12;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

7.22 Write a statement that displays the contents of the last column of the last row of
the array defined in Question 7.20.

A

7.22 cout &laquo_space;sales[5][3];

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

7.23 Define a two-dimensional array named settings large enough to hold the table
of data below. Initialize the array with the values in the table.
12 24 32 21 42
14 67 87 65 90
19 1 24 12 8

A

7.23 int settings[3][5] = {{12, 24, 32, 21, 42},
{14, 67, 87, 65, 90},
{19, 1, 24, 12, 8}};

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

7.24 Fill in the table below so it shows the contents of the following array:
int table[3][4] = {{2, 3}, {7, 9, 2}, {1}};

A

2 3 0 0
7 9 2 0
1 0 0 0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q
7.25 Write a function called displayArray7. The function should accept a twodimensional
array as an argument and display its contents on the screen. The
function should work with any of the following arrays:
int hours[5][7];
int stamps[8][7];
int autos[12][7];
int cats[50][7];
A

7.25 void displayArray7(int arr[][7], int rows)
{
for (int x = 0; x

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

7.26 A video rental store keeps DVDs on 50 racks with 10 shelves each. Each shelf
holds 25 DVDs. Define a three-dimensional array large enough to represent the
store s storage system.

A

7.26 int vidNum[50][10][25];

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

7.27 What header file must you #include in order to define vector objects?

A

7.27 vector

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

7.28 Write a definition statement for a vector named frogs. frogs should be an
empty vector of ints.

A

7.28 vector frogs;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

7.29 Write a definition statement for a vector named lizards. lizards should be a
vector of 20 floats.

A

7.29 vector lizards(20);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

7.30 Write a definition statement for a vector named toads. toads should be a vector
of 100 chars, with each element initialized to ‘Z’.

A

7.30 vector toads(100, ‘Z’);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

7.31 gators is an empty vector of ints. Write a statement that stores the value 27 in
gators.

A
  1. 31 vector gators;

gators. push_back(27);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

7.32 snakes is a vector of doubles, with 10 elements. Write a statement that stores
the value 12.897 in element 4 of the snakes vector.

A

7.32 snakes[4] = 12.897;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

Short Answer

1. What is the difference between a size declarator and a subscript?

A
  1. The size declarator is used in a definition of an array to indicate the number of elements the
    array will have. A subscript is used to access a specific element in an array.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
34
Q
  1. Look at the following array definition.
    int values[10];
    How many elements does the array have?
    What is the subscript of the first element in the array?
    What is the subscript of the last element in the array?
    Assuming that an int uses four bytes of memory, how much memory does the array use?
A

10
zero
9
40 bytes of memory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
35
Q
  1. Why should a function that accepts an array as an argument, and processes that
    array, also accept an argument specifying the array s size?
A
  1. Because, with the array alone the function has no way of determining the number of elements
    it has.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
36
Q
  1. Consider the following array definition:
    int values[5] = { 4, 7, 6, 8, 2 };
    What does each of the following statements display?
    cout
A

will display value2;
will display value 14;
will display value 8

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
37
Q
  1. How do you define an array without providing a size declarator?
A
  1. By providing an initialization list. The array is sized to hold the number of values in the list.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
38
Q
  1. Look at the following array definition.
    int numbers[5] = { 1, 2, 3 };
    What value is stored in numbers[2]?
    What value is stored in numbers[4]?
A

given an array definition.

int numbers[5] = {1, 2, 3};
the value stored in numbers[2] is 3.
the value stored in number[4] is 0, because it’s value not initialized

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
39
Q
  1. Assuming that array1 and array2 are both arrays, why is it not possible to assign
    the contents of array2 to array1 with the following statement?
    array1 = array2;
A
  1. Because an array name without brackets and a subscript represents the array’s beginning
    memory address. The statement shown attempts to assign the address of array2 to array1,
    which is not permitted.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
40
Q
  1. Assuming that numbers is an array of doubles, will the following statement display
    the contents of the array?
    cout &laquo_space;numbers &laquo_space;endl;
A

cout &laquo_space;numbers &laquo_space;endl;

the statement will not display the contents of array instead it display memory address

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
41
Q
  1. Is an array passed to a function by value or by reference?
A
  1. By reference.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
42
Q
  1. When you pass an array name as an argument to a function, what is actually being
    passed?
A

passing array name to function will pass address of array of integers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
43
Q
  1. How do you establish a parallel relationship between two or more arrays?
A
  1. By using the same subscript value for each array.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
44
Q
  1. Look at the following array definition.
    double sales[8][10];
    How many rows does the array have?
    How many columns does the array have?
    How many elements does the array have?
    Write a statement that stores a number in the last column of the last row in the array.
A

double sales[8][10];

array has 8 rows
array has 10 columns
array has 80 elements

sales[7][9]=52.61, stores the number in the last column of the last row in the array

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
45
Q
  1. When writing a function that accepts a two-dimensional array as an argument, which
    size declarator must you provide in the parameter for the array?
A
  1. The second size declarator, which is for the number of columns.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
46
Q
  1. What advantages does a vector offer over an array?
A
  1. you do not have to declare the number of elements that a vector will have;
  2. if you add a value to a vector that is already full, the vector will automatically increase its size to accommodate the new data
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
47
Q

Fill-in-the-Blank

15. The _________ indicates the number of elements, or values, an array can hold.

A
  1. size declarator
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
48
Q
  1. The size declarator must be a(n) _________ with a value greater than _________.
A

integer / zero

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
49
Q
  1. Each element of an array is accessed and indexed by a number known as a(n)
    _________.
A
  1. subscript
50
Q
  1. Subscript numbering in C++ always starts at _________.
A

zero

51
Q
  1. The number inside the brackets of an array definition is the _________, but the number
    inside an array s brackets in an assignment statement, or any other statement that
    works with the contents of the array, is the _________.
A
  1. size declarator, subscript
52
Q
  1. C++ has no array _________ checking, which means you can inadvertently store data
    past the end of an array.
A

bounds

53
Q
  1. Starting values for an array may be specified with a(n) _________ list.
A
  1. initialization
54
Q
  1. If an array is partially initialized, the uninitialized elements will be set to _________.
A

zero

55
Q
  1. If the size declarator of an array definition is omitted, C++ counts the number of items
    in the _________ to determine how large the array should be.
A
  1. initialization list
56
Q
  1. By using the same _________ for multiple arrays, you can build relationships between
    the data stored in the arrays.
A

subscript

57
Q
  1. You cannot use the _________ operator to copy data from one array to another in a
    single statement.
A
  1. =
58
Q
  1. Any time the name of an array is used without brackets and a subscript, it is seen as
    _________.
A

array’s beginning memory address

59
Q
  1. To pass an array to a function, pass the _________ of the array.
A
  1. address, or name
60
Q
  1. A(n) _________ array is like several arrays of the same type put together.
A

two dimensional

61
Q
  1. It s best to think of a two-dimensional array as having _________ and _________.
A
  1. rows, columns
62
Q
  1. To define a two-dimensional array, _________ size declarators are required.
A

two

63
Q
  1. When initializing a two-dimensional array, it helps to enclose each row s initialization
    list in _________.
A
  1. braces
64
Q
  1. When a two-dimensional array is passed to a function the _________ size must
    be specified.
A

column

65
Q
  1. The ____________________ is a collection of programmer-defined data types and
    algorithms that you may use in your programs
A
  1. Standard Template Library (or STL)
66
Q
  1. The two types of containers defined by the STL are ___________ and
    ______________.
A

sequence containers / associative containers

67
Q
  1. The vector data type is a(n) ______________ container.
A
  1. sequence
68
Q
  1. To define a vector in your program, you must #include the ____________ header
    file.
A

vector

69
Q
  1. To store a value in a vector that does not have a starting size, or that is already full,
    use the ________________ member function.
A
  1. push_back
70
Q
  1. To determine the number of elements in a vector, use the _____________ member
    function.
A

size

71
Q
  1. Use the ________________ member function to remove the last element from a vector.
A
  1. pop_back
72
Q
  1. To completely clear the contents of a vector, use the ___________ member function.
A

clear

73
Q

Algorithm Workbench
41. names is an integer array with 20 elements. Write a for loop that prints each element
of the array.

A
  1. for (int i = 0; i < 20; i++)

cout &laquo_space;names[i] &laquo_space;endl;

74
Q
  1. The arrays numberArray1 and numberArray2 have 100 elements. Write code that
    copies the values in numberArray1 to numberArray2.
A

const int size = 100;
for(int i =0; i<size;i++)
numberArray2[i] = numberArray1[i]

75
Q
  1. In a program you need to store the identification numbers of 10 employees (as ints)
    and their weekly gross pay (as doubles).
    A) De ne two arrays that may be used in parallel to store the 10 employee identi cation
    numbers and gross pay amounts.
    B) Write a loop that uses these arrays to print each employee s identi cation number
    and weekly gross pay.
A
43. const int SIZE = 10;
int id[SIZE]; // To hold ID numbers
double weeklyPay[SIZE]; // To hold weekly pay
// Display each employee's gross weekly pay.
for (int i = 0; i
76
Q
  1. Define a two-dimensional array of integers named grades. It should have 30 rows
    and 10 columns.
A

int grades[30][10];

77
Q
  1. In a program you need to store the populations of 12 countries.
    A) Define two arrays that may be used in parallel to store the names of the countries
    and their populations.
    B) Write a loop that uses these arrays to print each country s name and its population.
A
45. const int SIZE = 12;
// A string array to hold the country names
string countries[SIZE];
// An array to hold populations
long populations[SIZE];
// Display each country's name and population.
for (int i = 0; i
78
Q
  1. The following code totals the values in two arrays: numberArray1 and
    numberArray2. Both arrays have 25 elements. Will the code print the correct sum of
    values for both arrays? Why or why not?
    int total = 0; // Accumulator
    int count; // Loop counter
    // Calculate and display the total of the first array.
    for (count = 0; count
A

see

79
Q
  1. Look at the following array definition.
    int numberArray[9][11];
    Write a statement that assigns 145 to the rst column of the rst row of this array.
    Write a statement that assigns 18 to the last column of the last row of this array.
A
  1. numberArray[0][0] = 145;

numberArray[8][10] = 18;

80
Q
48.
values
is a two-dimensional array of
float
s with 10 rows and 20 columns. Write
code that sums all the elements in the array and stores the sum in the variable
total
.
A

int row, col;
float total = 0.0;

for (row = 0; row < 10; row ++)
{
for(col = 0; col <20; col++)
total +=value[row][col];

81
Q
  1. An application uses a two-dimensional array defined as follows.
    int days[29][5];
    Write code that sums each row in the array and displays the results.
    Write code that sums each column in the array and displays the results.
A
49. const int NUM_ROWS = 29;
const int NUM_COLS = 5;
int row, col, // Loop counters
total; // Accumulator
// Display the sum of each row.
for (row = 0; row
82
Q

True or False

50. T F An array s size declarator can be either a literal, a named constant, or a variable.

A

f
as array size declarator must be a constant integer expression with a value greater than zero. it can be either a literal or a named constant

83
Q
  1. T F To calculate the amount of memory used by an array, multiply the number of
    elements by the number of bytes each element uses.
A

t

84
Q
  1. T F The individual elements of an array are accessed and indexed by unique
    numbers.
A

t

85
Q
  1. T F The first element in an array is accessed by the subscript 1.
A

f

86
Q
  1. T F The subscript of the last element in a single-dimensional array is one less than
    the total number of elements in the array.
A

t

87
Q
  1. T F The contents of an array element cannot be displayed with
    cout
    .
A

f

88
Q
  1. T F Subscript numbers may be stored in variables.
A

t

89
Q
  1. T F You can write programs that use invalid subscripts for an array.
A

t

90
Q
  1. T F Arrays cannot be initialized when they are defined. A loop or other means must
    be used.
A

f

as array can be initialized when they are defined

91
Q
  1. T F The values in an initialization list are stored in the array in the order they
    appear in the list.
A

t

92
Q
  1. T F C++ allows you to partially initialize an array.
A

t

93
Q
  1. T F If an array is partially initialized, the uninitialized elements will contain
    “garbage”.
A

f

94
Q
  1. T F If you leave an element uninitialized, you do not have to leave all the ones that
    follow it uninitialized.
A

f

all the elements followed it are un initialized as will

95
Q
  1. T F If you leave out the size declarator of an array definition, you do not have to
    include an initialization list.
A

f

96
Q
64. T F The uninitialized elements of a
string
array will automatically be set to the
value
"0"
.
A

t

97
Q
  1. T F You cannot use the assignment operator to copy one array s contents to
    another in a single statement.
A

t

98
Q
  1. T F When an array name is used without brackets and a subscript, it is seen as the
    value of the first element in the array.
A

f

an array name without brackets and a subscript indicates array’s beginning memory address

99
Q
  1. T F To pass an array to a function, pass the name of the array.
A

t

100
Q
  1. T F When defining a parameter variable to hold a single-dimensional array argument,
    you do not have to include the size declarator.
A

f

as size declarator must be specified in order to process elements in function

101
Q
  1. T F When an array is passed to a function, the function has access to the original
    array.
A

t

102
Q
  1. T F A two-dimensional array is like several identical arrays put together.
A

t

103
Q
  1. T F It s best to think of two-dimensional arrays as having rows and columns.
A

t

104
Q
  1. T F The first size declarator (in the declaration of a two-dimensional array) represents
    the number of columns. The second size definition represents the number
    of rows.
A

f, as first size declarator represents the number of rows and second represents the number of columns

105
Q
  1. T F Two-dimensional arrays may be passed to functions, but the row size must be
    specified in the definition of the parameter variable.
A

f

106
Q
  1. T F C++ allows you to create arrays with three or more dimensions.
A

t

107
Q
  1. T F A vector is an associative container.
A

f

108
Q
  1. T F To use a vector, you must include the vector header file.
A

t

109
Q
  1. T F vectors can report the number of elements they contain.
A

t

110
Q
  1. T F You can use the [] operator to insert a value into a vector that has no elements.
A

f

only using function push_back(value) we can insert data to vector

111
Q
  1. T F If you add a value to a vector that is already full, the vector will automatically
    increase its size to accommodate the new value.
A

t

112
Q

Find the Error
Each of the following definitions and program segments has errors. iLocate as many as you can.
80. int size;
double values[size];

A

must be provided with initial value and used in next statement

113
Q
  1. int collection[-20];
A
  1. The size declarator cannot be negative.
114
Q
82. int table[10];
for (int x = 0; x < 20; x++)
{
cout << "Enter the next value: ";
cin >> table[x];
}
A

invalid access of array

115
Q
  1. int hours[3] = 8, 12, 16;
A
  1. The initialization list must be enclosed in braces.
116
Q
  1. int numbers[8] = {1, 2, , 4, , 5};
A

two of initialization values are left out

117
Q
  1. float ratings[];
A
  1. For the array to be implicitly sized there must be an initialization list.
118
Q
  1. char greeting[] = {‘H’, ‘e’, ‘l’, ‘l’, ‘o’};

cout &laquo_space;greeting;

A

a null terminator must be specified in the intialization list

119
Q
  1. int array1[4], array2[4] = {3, 6, 9, 12};

array1 = array2;

A
  1. The assignment operator cannot be used to assign the contents of one array to another, in a
    single statement.
120
Q
88. void showValues(int nums)
{
for (int count = 0; count < 8; count++)
cout << nums[count];
}
A

the function should have a parameter to hold array elements and size parameter must also be there

121
Q
89. void showValues(int nums[4][])
{
for (rows = 0; rows < 4; rows++)
for (cols = 0; cols < 5; cols++)
cout << nums[rows][cols];
}
A
  1. The parameter must specify the number of columns, not the number of rows.