CFORBEGINNERS.COM

Search Google

C Quiz on Arrays

1. Which is the correct way to declare an array?
    a) my_array [5];
    b) my_array (5);
    c) my_array {5};

2. What do arrays do?
    a) hold addresses
    b) hold values under a single name
    c) hold one value

3. double num [7]; what is the name of this array?
    a) double
    b) has no name
    c) num

4. From question 3, how many values will that array hold?
    a) 7
    b) 8
    c) 6

5. From question 3, what is the greatest index number?
    a) 7
    b) 6
    c) 8

6. What is the correct way to initialize values in an array?
    a) my_array [5] = (5,3,4,2,7);
    b) my_array [5] = {5;3;4;2;7};
    c) my_array [5] = {5,3,4,2,7};

7. From question 5, what is the value of my_array [2]?
    a) 7
    b) 3
    c) 4

8. Can an entire array be printed out at once?
    a) yes
    b) no

9. What is the most efficient way to assign or print out arrays?
    a) loops
    b) functions
    c) pointers