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

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

ID: 3543342 • Letter: 1

Question

1. (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) Which of the following techniques can be used to process the elements of a multidimensional array? (Points : 3)       Nested selection structure
      Nested looping structure
      Sequence structure
      None of the above

3. (TCO 11) A five-row, six-column array has a total of how many elements? (Points : 3)       1
      36
      30
      11

4. (TCO 12) Given the following array:

int profit [5] = {10, 20, 31, 55, 66};

The following statement would replace which value?
profit [0] = profit[2]; (Points : 3)       10 with 31
      10 with 20
      20 with 31
      10 with 55

5. (TCO 12) What is the character automatically included at the end of an array of characters? (Points : 3)       
      
      z
      *

6. (TCO 11) In the following table, what is the value of table[2][1]?
int table[3][4]={3,7,0,2,4,9,8,1,3,6,5,4};
(Points : 3)       4
      7
      6
      1

7. (TCO 11) What type of error will this code produce?

int n[30], i;
for(i = 0; i <= 30; ++i)
     n[i] = i; (Points : 3)       No compiler errors will be reported.
      A compiler error is generated since there are no braces {} with the for loop.
      A runtime error may occur because we are out of bounds on the array.
      No compiler errors will be reported, but a runtime error may occur because we are out of bounds on the array.


8. (TCO 11) Is it possible to write code in this manner for a C++ program?

int break;
cout << "What time is your break?";
cin >> break;
int numbers[break]; (Points : 3)       Yes, this is perfectly acceptable C++ code.
      No, the array dimension cannot be a variable.
      The compiler would report that there is an illegal use of a keyword.
      Yes, this is perfectly acceptable C++ code, but the compiler would report that there is an illegal use of a keyword.


9. (TCO 11) What is wrong with this code?

void WriteDay(char d[]);
int main( )
{
     char Day [10] = "Friday";
     WriteDay(Day[]);
     return 0;
} (Points : 3)       The brackets are not needed in the call statement.
      Friday is too short for the array.
      The code is correct as written.
      The call statement should be written as WriteDay(Day[10]);

10. (TCO 12) Assuming that t is an array and tPtr is a pointer to that array, which expression refers to the address of element 3 of the array? (Points : 3)       *( tPtr + 3 )
      tPtr[ 3 ]
      &t[ 3 ]
      *( t + 3 )

11. (TCO 11) Explain how to declare and assign values to a two-dimensional array and provide a C++ program segment that illustrates your answer. Provide a summary of how the values are stored. (Points : 5) 11. (TCO 11) Explain how to declare and assign values to a two-dimensional array and provide a C++ program segment that illustrates your answer. Provide a summary of how the values are stored. (Points : 5) 1. (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

Explanation / Answer

1 d
2 a
3 c
4 d
5 b
6 d
7 in c no error(a) but in java it is error (d)
8 c
9 a
10 a
11


#include<iostream>

using namespace std;



int main()

{

int arr[4][4]={ 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};

int i,j;


for(i=0;i<4;i++)

{

for(j=0;j<4;j++)

{

cout<<arr[i][j]<<" ";

}

cout<<" ";

}

return 0;

}