How do you declare an array of integers containing 5 elements?

20242024

How do you declare an array of integers containing 5 elements?

  1. A.

    int array[5];

  2. B.

    int array;

  3. C.

    array int[5];

  4. D.

    int array();

Attempted by 1022 students.

Show answer & explanation

Correct answer: A

In C, an array declaration includes the data type, followed by the array name and its size enclosed within square brackets. In this case, int array[5]; declares an integer array of 5 elements. The elements are uninitialized and will contain garbage values.

Explore the full course: Cocubes Preparation