Arrays in C++ MCQs: 12 Solved Questions with Explanations

Solve 12 published array MCQs with clear explanations of indexing, pointers, character buffers, declarations and multidimensional arrays.

KnowledgeGate Team

Exam prep & CS education

26 Oct 20268 min read

Array MCQs test four models: zero-based indexing, contiguous layout, array-to-pointer conversion and row-major flattening. Array problems range from basic properties and unusual subscripts to character arrays, pointer declarations, dynamic-array cleanup and three-dimensional indexing.

Choose each answer and write one line of reasoning before reading its explanation. Place unfamiliar rules within the wider Coding & DSA sequence instead of memorising isolated options.

The array model to use before solving

A built-in array stores a fixed number of same-type elements contiguously. Indexing starts at 0; A[i] means *(A + i), so its byte address is base + i * element size. Contiguous storage still permits direct access without visiting earlier elements. This model often eliminates tempting options.

For int A[5] = {10, 20, 30, 40, 50}, take base address 2048 and sizeof(int) = 4 bytes. Its addresses are 2048, 2052, 2056, 2060 and 2064. The third element is A[2] = 30, and 2[A] = *(2 + A) = *(A + 2) = 30. After A[2] += 7, both A[2] and *(A + 2) read 37.

For int B[3][4][5], again take base 2048 and 4-byte integers. At B[2][1][3], the row-major linear index is 2 * (4 * 5) + 1 * 5 + 3 = 48; its address is 2048 + 48 * 4 = 2240. Question 11 uses the same flattening. Arrays in C: Declaration, Initialization and Worked Examples owns the declaration, traversal, insertion, deletion and row-major foundations; this set applies those rules to C++ exam questions and compile checks.

Arrays in C++ MCQs 1-3: layout, random access and subscript equivalence

Question 1 (NVS 2019)

Which of the following statements about Array in C++ is FALSE?

  • A. Generally, arrays are of fixed size.

  • B. Array elements are stored in continuous memory locations.

  • C. All elements of an array are of same data type.

  • D. Array elements can only be accessed sequentially.

Answer: D.

Contiguous describes storage, not access. Indexing jumps directly to any valid element, so A[7] requires no earlier reads. D is false.

Question 2 (TPSC 2025)

What will be the output of the below code?

cpp
#include <iostream>
using namespace std;

int main()
{
    int arr[2] = {1, 2};

    cout << 0[arr] << ", " << 1[arr] << endl;

    return 0;
}
  • A. 1, 2

  • B. Syntax error

  • C. Run time error

  • D. None of these

Answer: A.

Since x[y] = *(x + y), 0[arr] = arr[0] = 1 and 1[arr] = arr[1] = 2. The literal adds the comma and space. This is legal but unclear.

Question 3 (DSSSB 2018)

Considering A as a one-dimensional array, which of the following C++ statements will print the third element of A?

  • A. cout << A[3];

  • B. cout << 3[A];

  • C. cout << 2[A];

  • D. cout >> A[2];

Answer: C.

The third element has index 2, and 2[A] = *(2 + A) = A[2]. A and B select the fourth; D reverses cout's operator.

Arrays in C++ MCQs 4-6: pointer movement, character buffers and compile errors

Question 4 (NVS 2017)

Find the output of the following C++ code:

int A[] = {20, 90, 70, 10};

int * P = A;

A[2] += 10;

P += 2;

cout << *P << endl;

  • A. 70

  • B. 80

  • C. 90

  • D. 10

Answer: B.

A[2] becomes 80. Then P += 2 moves from A[0] to that updated element, so *P is 80.

Question 5 (DSSSB 2018)

What will be the output of the following C++ program?

# include <iostream>

using namespace std;

int main(){

char array[10];

int i;

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

*(array + i) = 65 + i;

*(array + i) = '\0';

cout << array;

return(0);

}

  • A. ABCDE\0

  • B. ABCDE

  • C. BCDEF

  • D. CDEFG

Answer: B.

Indices 0 to 4 receive codes 65 to 69, or A to E. At i = 5, the null terminator makes output stop; \0 is invisible. The earlier Character Pointer (String) MCQs in C owns string-pointer traces and terminator failures; this question only tests constructing one character buffer.

Question 6 (BPSC 2023)

What will be the output of the following C++ code?

cpp
#include<iostream>
#include<string>
using namespace std;
int main(int argc, char *argv[])
{
    char s1[6] = "Hello";
    char s2[6] = "World";
    char s3[12] = s1 + " " + s2;
    cout << s3;
    return 0;
}
  • A. Hello

  • B. World

  • C. Error

  • D. More than one of the above

  • E. None of the above

Answer: C.

The arrays decay to pointers, and C++ defines no pointer-plus-pointer concatenation. Compilation fails before buffer size matters. Use std::string or explicit copying.

Arrays in C++ MCQs 7-9: declarations, dynamic cleanup and logical deletion

Question 7 (NVS 2019)

Which of the given options best describes the following array declaration in C++?

int (*arr)[5];

  • A. It declares a pointer to an integer array of five elements.

  • B. It declares an array of five integer pointers.

  • C. It declares an array of ten integer pointers.

  • D. It declares a pointer to a character array of five elements.

Answer: A.

Read outwards from arr. Parentheses bind *arr first, making a pointer to five int elements. Without parentheses, int *arr[5] is five pointers.

Question 8 (KVS 2017)

In C++, which of the following statements correctly returns the memory from the dynamic array pointer pp to the free store?

  • A. delete pp;

  • B. delete pp [ ];

  • C. delete [ ] pp;

  • D. *delete pp;

Answer: C.

Pair new T[n] with delete[] pp; spaces change nothing. Scalar delete pp pairs with scalar new. The other forms are invalid.

Question 9 (Beltron Programmer 2025)

Which method correctly removes an element at a given index from a one-dimensional array in C++?

  • A. Shift all elements after the target index one position left and reduce the array size by one

  • B. Simply reduce the array size without moving any elements

  • C. Swap the element with the last element and reduce the array size without shifting

  • D. Set the element to zero and keep the array size the same

Answer: A.

Deleting index 2 from [12, 25, 38, 41, 59] shifts 41 and 59 left, giving logical size 4 and [12, 25, 41, 59]. Capacity stays fixed; swapping loses order.

Arrays in C++ MCQs 10-12: dimensions, row-major addresses and cubic work

Question 10 (BPSC 2023)

In C++, for what purpose is the "rank()" used?

  • A. It returns the size of each dimension

  • B. It returns the maximum number of elements that can be stored in the array

  • C. It returns the dimension of the specified array

  • D. More than one of the above

  • E. None of the above

Answer: C.

Here, rank means dimension count: 1 for a one-dimensional array and 3 for int B[3][4][5]. It gives neither extents nor capacity 60. Built-in arrays have no runtime rank() member.

Question 11 (UGC NET 2023)

A three dimensional array in C++ is declared as:

cpp
int A[a][b][c];

Consider that array elements are stored in row-major order and indexing begins from 0.

Here, the address of an item at the location A[r][s][t] computed in terms of word length w of an integer is:

  • A. &A[0][0][0]+w(b*c*s+c*r+t)

  • B. &A[0][0][0]+w(b*c*r+c*s+t)

  • C. &A[0][0][0]+w(a*b*r+c*s+t)

  • D. &A[0][0][0]+w(a*b*s+c*r+t)

Answer: B.

Advancing r, s or t skips bc, c or one element, giving rbc + sc + t. Treating the base as a numeric byte address, as the options do, A[2][1][3] in A[3][4][5] has linear index 2 * 4 * 5 + 1 * 5 + 3 = 48. With w = 4 and base 2048, the byte address is 2048 + 48 * 4 = 2240. Thus B matches. In literal C++ pointer arithmetic, adding 48 to an int pointer already scales by sizeof(int).

Question 12 (IBPS 2023)

Assuming each arithmetic and output operation takes constant time, what is the overall time complexity of the following code?

cpp
#include <iostream>
#include <vector>
using namespace std;
int main() {
    int n;
    cout << "Enter the size of the 3D matrix (n x n x n): ";
    cin >> n;
    vector<vector<vector<int>>> matrix(
        n,
        vector<vector<int>>(n, vector<int>(n))
    );
    cout << "3D Matrix with sums at each coordinate (i, j, k): " << endl;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            for (int k = 0; k < n; k++) {
                matrix[i][j][k] = i + j + k;
                cout << "Value at ("
                     << i << ", "
                     << j << ", "
                     << k << ") = "
                     << matrix[i][j][k]
                     << endl;
            }
        }
    }
    return 0;
}
  • A. O(n)

  • B. O(n^2)

  • C. O(n^3)

  • D. O(n log n)

  • E. O(log n)

Answer: C.

Three loops run the body n * n * n = n^3 times, or 64 at n = 4. Under the stated assumption, traversal and construction remain O(n^3).

The traps these 12 array questions expose

Cue

Questions

Check

Sequential layout permits direct access

Q1

Apply the address formula.

x[y] equals y[x]

Q2-Q3

Expand it.

Mutation, movement and termination change results

Q4-Q6

Update, then compile-check.

Parentheses, delete[] and logical size differ

Q7-Q9

Read outwards.

Rank, offsets and loop depth differ

Q10-Q12

Count the right quantity.

For a timed solve:

  1. Mark type and bounds.

  2. Record mutations.

  3. Expand subscripts.

  4. Check compilation.

  5. Multiply remaining dimensions.

The earlier Other Array Types MCQs owns bit arrays, parallel arrays, dynamic-array size and capacity, sparse matrices and heap-backed arrays. This set stays with built-in C++ arrays, pointer decay, delete[], logical deletion and row-major indexing.

Arrays in C++: the next practice step

Redo Q2, Q4, Q6, Q7, Q9 and Q11 without the answers. They test subscript equivalence, state tracing, compilation, declaration binding, logical deletion and row-major addressing. For gaps, follow the C++ Programming course through concepts, MCQs and coding practice.

Write the base type, bounds, current contents and exact address or pointer transformation. Do this before trusting a familiar-looking option, then justify the answer in one reproducible line.