SSL Certificate
  • If n represents the size of an array, what would be the index



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) Programmers often mistakenly reference the first element in an array with index1. What is this called? (Points : 3)
        Logic-error
        Index1-error
        off-by-one-error
        N-1



3. (TCO 11) A three-row, four-column array has a total of how many elements? (Points : 3)
        7
        12
        16
        1



4. (TCO 12) Given the following array:


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


The following statement would replace which value?
profit [4] = profit[1] + 4; (Points : 3)
        55 with 14
        66 with 14
        66 with 24
        55 with 24



5. (TCO 12) In the variable initialization: char course[20] = Welcome to CIS170C ; the character at course[6] will be _____. (Points : 3)
        \0
        the letter m
        the letter e
        a space



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



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?


char auto;
cout << "what kind of automobile do you have?";
cin >> auto;
char cars[auto]; (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 comopiler would report that there is an illegal use of a keyword.




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


WriteGreeting(char greetings[ ]);
int main()
{
     char greetings[3][10]= {"hello", "howdy', "hi"} ;
     WriteGreeting(greetings);
     return 0;
}


WriteGreeting(char greetings[ ] )
{
     for(int I = 0; I < 3; ++I)
     cout<<greeting[I];
} (Points : 3)
        The function prototype has a number in the second array dimension brackets.
        There are only three items in the array list.
        The code is correct.
        The function header needs the second array dimension size specified as in prototype.



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 determine the number of elements in a previously defined single-dimension array. Provide a C++ program segment that illustrates your answer. (Points : 5)


 


Write a review

Please login or register to review

If n represents the size of an array, what would be the index

  • $9.99


*All your data are SECURED & ENCRYPTED using a valid, trusted server certificate (Comodo SSL) and we don't store credit card information on our servers and all Payments are SECURED & handled by Paypal.
SSL CertificatePaypal

Tags: Multiple choice question, MCQ, c++, cpp, object oriented programming, oop, writeup