Solutions to Quiz 8: Arrays

If you didn't do as well as you wanted, be sure to read through Cprogramming.com's tutorial on Arrays. Otherwise, good job! I'm sure you'll use arrays a great deal in your programming, and it's good that you're already getting comfortable with them.

1. Which of the following correctly declares an array?
A. int anarray[10];
B. int anarray;
C. anarray{10};
D. array anarray[10];

2. What is the index number of the last element of an array with 29 elements?
A. 29
B. 28
C. 0
D. Programmer-defined

3. Which of the following is a two-dimensional array?
A. array anarray[20][20];
B. int anarray[20][20];
C. int array[20, 20];
D. char array[20];

4. Which of the following correctly accesses the seventh element stored in foo, an array with 100 elements?
A. foo[6];
B. foo[7];
C. foo(7);
D. foo;

5. Which of the following gives the memory address of the first element in array foo, an array with 100 elements?
A. foo[0];
B. foo;
C. &foo;
D. foo[1];


Quiz
Next lesson: Lesson 9, strings