Home » C Programming » Functions » Question
  1. What will be the output of the following C code?
    #include <stdio.h>
    int *fun();
    void main()
    {
    int n = A();
    printf("%d", n);
    }
    int *fun()
    {
    int num[5] = {51, 18, 25};
    return num;
    }
    1. 51 18 25
    2. 25 18 51
    3. 18 25 51
    4. Compilation Error
    5. None of these
Correct Option: A

Compilation Error

main.c: In function ‘main’:
main.c:5:17: warning: implicit declaration of function ‘A’ [-Wimplicit-function-declaration]
int n = A();
^
main.c: In function ‘fun’:
main.c:11:16: warning: function returns address of local variable [-Wreturn-local-addr]
return num;
^~~
/tmp/ccNdhoL1.o: In function `main':
main.c:(.text+0xe): undefined reference to `A'
collect2: error: ld returned 1 exit status



Your comments will be displayed only after manual approval.