Which of the following correctly declares an array?

2008

Which of the following correctly declares an array?

  1. A.

    int geeks[20];

  2. B.

    int geeks;

  3. C.

    geeks{20};

  4. D.

    array geeks[20];

Attempted by 1531 students.

Show answer & explanation

Correct answer: A

The correct syntax to declare an array in C/C++ involves specifying the data type, followed by the variable name and the size enclosed in square brackets. For instance, int geeks[20]; is valid. Other options may declare single variables or use incorrect syntax.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Isro