Arrays
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];

6.

What is a array ?

A.  

An array is a series of elements of the same type in contiguous memory locations

B.  

An array is a series of element

C.  

An array is a series of elements of the same type placed in non-contiguous memory locations

D.  

None of the mentioned

7.

Which of the following accesses the seventh element stored in array ?

A.  

array[6];

B.  

array[7];

C.  

array(7);

D.  

array;

8.

Which of the following gives the memory address of the first element in array ?

A.  

array[0];

B.  

array[1];

C.  

array(2);

D.  

array;

9.

What will be the output of this program ?

 #include <stdio.h>
    using namespace std;
    int array1[] = {1200, 200, 2300, 1230, 1543};
    int array2[] = {12, 14, 16, 18, 20};
    int temp, result = 0;
    int main()
    {
        for (temp = 0; temp < 5; temp++) {
            result += array1[temp];
        }
        for (temp = 0; temp < 4; temp++) {
            result += array2[temp];
        }
        cout << result;
        return 0;
    }
A.  

6553

B.  

6533

C.  

6522

D.  

12200

10.
 #include <stdio.h>
    using namespace std;
    int main ()
    {
        int array[] = {0, 2, 4, 6, 7, 5, 3};
        int n, result = 0;
        for (n = 0 ;n < 8 ;n++) {
            result += array[n];
        }
        cout << result;
        return 0;
    }
A.  

25

B.  

26

C.  

27

D.  

None of the mentioned