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

1. What best describes what must go inside the brackets to declare an array, e.g

ID: 3567911 • Letter: 1

Question

1. What best describes what must go inside the brackets to declare an array, e.g. int arr[?????]; ?

Select one:

a. none of the other answers

b. CONSTANT

c. ConstIntExpression

d. a number

e. bool

f. an expression

g. int

h. NumberValue

i. float

j. string

2. As shown in the text to ReverseNumbers, you can print the numbers backwards by using which of the following?

Select one:

a. while ( value > 0 )

b. while ( number != 0 )

c. while ( value <= 1000 )

d. for (number = 999; number >= 0; number--)

e. for ( number == 999 ; number >= 0 ; number++ )

f. for (value = 999 ; value > 0 ; value-- )

g. for ( int value = 0 ; value <= 1000 ; value++ )

h. while ( number >= 0 )

i. while ( i < number )

j. for ( int i = 0 ; i < number ; i++ )

k. none of the other answers

3. How do you add up all of the elements in an array with NUM_ELEMENTS elements? (fill in the blank)

float arr[NUM_ELEMENTS];

double total=0;

...

for ( int i = 0 ; i < NUM_ELEMENTS; i++ )

________________________________;

Select one:

a. none of the other answers

b. total += arr;

c. float total += arr[i];

d. double total = total + arr[i];

e. total += arr[i];

f. int total = total + arr[i];

g. total = total + arr;

h. total = arr[i];

i. total = total[i];

4. In the following code, what value goes in the blank to print all of the weights?

5. When an array has, for example, 100 elements, but your program accesses an element above the number of elements, like 200, it is called using an array index out-of-bounds. This is a common programming problem. What happens when a programmer assigns a value to an array element like this in a C++ program?

Select one:

a. the assignment is ignored

b. the last value in the array is assigned instead

c. memory outside the array is incorrectly assigned

d. such code doesn't compile

e. none of the other answers

f. a programmer never does this

g. the program crashes

h. such code compiles but won't run

6. An array index starts at __ ?

7. Brackets are ________________.

In an array declaration, brackets are used around the number of elements you want an array to contain.

Select one:

a. pointy

b. up

c. down

d. stupid

e. cool

f. square

g. none of the other answers

h. curly

i. round

8. To access a particular component, you give the name of the array and an Answer to reference a single, specific element in the array. (1 word)

9. For this array, what do you put in the brackets to assign the last element in the array to value?

int numbers[100];

value = numbers[Answer];

Explanation / Answer

1.CONSTANT

2.h. while ( number >= 0 )

3.e. total += arr[i];

4.999

5.h. such code compiles but won't run

6. 0

7.f. square


8.index

9.99