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

. (TCO 11) If n represents the size of an array, what would be the index of the

ID: 3543453 • Letter: #

Question

. (TCO 11) If n represents the size of an array, what would be the index of the last element in the array? (Points : 3)                                           n-2
                                        n
                                        n-1
                                        Cannot be determined
                                            
                         

                     2. (TCO 11) When working with an array, the easiest way to traverse or visit all elements of the array is to _____. (Points : 3)                                           use a loop statement
                                        sort the array and read it
                                        do a binary search
                                        use sequential coding
                         

Explanation / Answer

1.      For an array of size n, Array indexing starts at 0. So the first element will be stored at index1, second element at index 2 and so on. The last element will be stored at index n-1.

2.      The elements of array can be processed by for loop statement.

3.      An array declared as 3 rows and 4 columns will have a total of 12 elements. It represents a 3X4 matrix. In arrays, indexing of the elements starts at 0. In a two-dimensional array myArray[3][4], the first element will be stored at index [0][0].

4.      In the array given, profit[] is initialized at the time of declaration. So initially profit [0] =10 and profit[1]=20, profit[2]=31. After the statement profit [0] =profit [2], profit [0] will have the value 31.

5.      An array of characters is called a string. Array indexing starts at 0. When char course[20]=Devry University, course[0] will contain D, course[1] will contain e, course[2] will contain v and so on.

6.      In multidimensional arrays, indexing of the elements starts at 0. Table [2][1] indicates that the element is in the 3rd row 2nd column. 6 represents the element table[2][1].

7.      The memory for the array will be allocated at the time of declaration. When an array is referenced beyond the boundary limits specified at the time of declaration, it is going to show an error message specifying out-of-bounds as the subscripts are beyond the boundaries.

8.      Auto is a keyword that specifies the automatic storage class. Using of keywords as variable name is not allowed in c or c++. So when the code specified is executed, the compiler will report