Home » C Programming » Arrays » Question
  1. What will be the output of the following C code?
    #include <stdio.h>
    int main()
    {
    N(num);
    }
    void N(int **num)
    {
    int n1 = 15, n2 = 15, n3 = 12;
    int *num[2];
    num[0] = &n1;
    num[1] = &n2;
    printf("%d\n", num[0][1]);
    }
    1. 15
    2. Undefined behaviour
    3. Compilation Error
    4. Garbage value
    5. None of these
Correct Option: C

Compilation Error

main.c: In function ‘main’:
main.c:4:9: warning: implicit declaration of function ‘N’ [-Wimplicit-function-declaration]
N(num);
^
main.c:4:11: error: ‘num’ undeclared (first use in this function)
N(num);
^~~
main.c:4:11: note: each undeclared identifier is reported only once for each function it appears in
main.c: At top level:
main.c:6:10: warning: conflicting types for ‘N’
void N(int **num)
^
main.c:4:9: note: previous implicit declaration of ‘N’ was here
N(num);
^
main.c: In function ‘N’:
main.c:9:14: error: ‘num’ redeclared as different kind of symbol
int *num[2];
^~~
main.c:6:18: note: previous definition of ‘num’ was here
void N(int **num)



Your comments will be displayed only after manual approval.