Home » C Programming » Arrays » Question
  1. What will be the output of the following C code?
    #include 
    void f(int n[5][])
    {
    n[0][4] = 11;
    int k = 0, L = 0;
    for (k = 0; k < 4; k++)
    for (L = 0; L < 5; L++)
    printf("%d", n[k][L]);
    }
    void main()
    {
    int n[4][5] = {0};
    f(n);
    }
    1. Garbage value Garbage value 11 Garbage value Garbage value
    2. Only garbage value
    3. Runtime Error
    4. 11
    5. Compilation Error
Correct Option: E

Compilation Error

main.c:2:16: error: array type has incomplete element type ‘int[]’
void f(int n[5][])
^
main.c:2:16: note: declaration of ‘n’ as multidimensional array must have bounds for all dimensions except the first
main.c: In function ‘main’:
main.c:13:11: error: type of formal parameter 1 is incomplete
f(n);



Your comments will be displayed only after manual approval.