Home » C Programming » Arrays » Question
  1. Which of the following is the correct output for the program given below?
    #include
    int main()
    {
    int arr[5] = {12, 23);
    printf("%d%d%d\n", a[2], a[3], a[4]);
    return 0;
    }
    1. Garbage values
    2. 2 3 3
    3. 3 2 2
    4. 0 0 0
Correct Option: D

When an automatic array is partially initialized, the remaining array elements are initialized to 0.

So the the initialization in the question will be equivalent to
int arr[5] = {12, 23, 0, 0, 0);



Your comments will be displayed only after manual approval.