Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Question 1 (1 point) Given an array of integers of size 5, how does the computer

ID: 3916579 • Letter: Q

Question

Question 1 (1 point)

Given an array of integers of size 5, how does the computer know where the 3rd indexed variable is located?

Question 1 options:

It adds 3 to the base address of the array

It adds space for 3 integers to the base address of the array

It remembers where all the indexed variables of the array are located.

None of the above

Save

Question 2 (1 point)

Which of the following declare an array of 5 characters, and initializes them to some known values?

Question 2 options:

char array[5]={'a','b','c','d','e'};

char array[4]={'a','b','c','d','e'};

char array[5]={''};

char array[]={'a','b','d','e'};

A and C

B and D

all of the above

Save

Question 3 (1 point)

The computer remembers the address of which indexed variable(s) in an array? ______

Question 3 options:

The center

The first

The memory location before the first

The Last

The memory location after the last

Save

Question 4 (1 point)

Question 4 options:

Indexes are numbered starting at _________

Save

Question 5 (1 point)

Question 5 options:

How many indexed variables does the following array have?
int myArray[12]={1,2,3,6,5,4,7,1,2};

Save

Question 6 (1 point)

The locations of the various indexed variables in an array can be spread out all over the memory.

Question 6 options:

True

False

Save

Question 7 (1 point)

The following function declaration guarantees the values in the array argument are not changed in the function.



void function1(int array[], int numElements);

Question 7 options:

True

False

Save

Question 8 (1 point)

Which of the following function declarations correctly expect an array as the first argument?

Question 8 options:

void f1(int array, int size);

void f1(int& array, int size);

void f1(int array[100], int size);

void f1(float array[], int size);

All of the above

C and D

A and B

Save

Question 9 (1 point)

If you use the const modifier in a function declaration, you do not include it in the function definition.

Question 9 options:

True

False

Save

Question 10 (1 point)

The modifier that guarantees that an array argument will not be changed is called ______.

Question 10 options:

range

permanent

const

domain

index

key

value

Save

Question 11 (1 point)

Which of the following declare an array of 5 characters, and initializes them to some known values?

Question 11 options:

A) char array[5]={'a','b','c','d','e'};

B) char array[4]={'a','b','c','d','e'};

C) char array[5]={'a'};

D) char array[]={'a','b','d','e'};

A and C

B and D

A, B, C and D

Save

Question 12 (1 point)

Give the following declarations, which of the following is a legal call to this function?
int myFunction(int myValue);

int myArray[1000];

Question 12 options:

cout << myFunction(myArray);

cout << myFunction(myArray[0]);

myArray = myFunction(myArray);

myArray[1] = myFunction(myArray[0]);

A and B

A and C

B and D

Save

Question 13 (1 point)

Given an array named scores with 25 elements, what is the correct way to access the 25th element?

Question 13 options:

scores+25

scores[24]

scores[25]

scores[last]

Save

Question 14 (1 point)

The computer remembers the address of which indexed variable(s) in an array? ______

Question 14 options:

The center

The first

The memory location before the first

The Last

The memory location after the last

Save

Question 15 (1 point)

Which of the following function declarations could be used to input data from the keyboard into the array?

Question 15 options:

void input(int array[], int &numElements, int MAX_SIZE);

void input(int array[], int numElements, int MAX_SIZE);

void input(int &array[], int numElements, int MAX_SIZE);

int array[] input(int array[], int umElements, int MAX_SIZE);

Save

Question 16 (1 point)

When you have a function that expects an array, it should also expect the size of the array or the number of indexed variables with valid data.

Question 16 options:

True

False

Save

Question 17 (1 point)

Question 17 options:

How many indexed variables does the following array have?
int myArray[12]={1,2,3,6,5,4,7,1,2};

Save

Question 18 (1 point)

The following function declaration guarantees the values in the array argument are not changed in the function.





void function1(const int array[], const int numElements);

Question 18 options:

True

False

Save

Question 19 (1 point)

The following function definition has an error in it. What line is this error on?
0. void f1(const double array[], int size)
1. {
2. int i=0;
3. while(i< size)
4. {
5. array[i] += 2;
6. cout <
7. i++;
8. }
9. }

Question 19 options:

0

2

5

6

2

Save

Question 20 (1 point)

In the expression
cout << score[i] << endl;
i is called the

Question 20 options:

base

key

range

delimiter

index

It adds 3 to the base address of the array

It adds space for 3 integers to the base address of the array

It remembers where all the indexed variables of the array are located.

None of the above

Explanation / Answer

1)      It adds 3 to the base address of the array because the computer only remembers the address of the first indexed variable in an array. Since it already is an integer array so the computer would itself take care of the space.

2)      A and C because the first one is straight forward we have 5 elements and the size of the array is also 5 so it will work , second option won’t work because of size 4 and elements 5,third option will work and assign each value as empty.

3)      The first , as explained in the first question the computer will only remember the address of the first element.

4)      0 ,the indexed are numbered starting at zero in an array.

5)      12, Since it has been declared as int myArray[12] = {1,2,3,6,5,4,7,1,2} the size is declared as 12.

6)      False, it would be contiguous not all spread throughout .

7)      False, because the values will be changed as we haven’t used something like const.

8)      C and D, because we need the syntax correct when we declare array in a function argument.

9)      False, we need to include it in the function definition.

10)   const, this modifier will guarantee that the array arguments won’t change.

11)   A and C , this is similar to the 2nd question.

12)   B and D , because the function is expecting a int and returning an int only not an array.

13)   scores[24], because in array the numbering starts from 0 hence the last element would be at index 24.

14)   The first, same as 3rd question.

15) void input(int &array[], int numElements, int MAX_SIZE). Because here we pass the array by reference.

16)   True, the function will also expect the size of the array

17)   12, same as 5th question.

18)   True, because we have used the const modifier.

19)   5 or 6, 5 because it is const array you can’t change its size and 6 because of the syntax cout(maybe that’s a typo from your side)

20)   Index, the i is called the index in array.