Home » C Programming » Pointers » Question
  1. What will be the output of the following C code?
     #include <stdio.h>
    int *fun();
    int main()
    {
    int *ptr = fun();
    printf("%d\n", *ptr);
    }
    int *fun()
    {
    int n = 12;
    return &n;
    }
    1. Segmentation fault
    2. Undefined behaviour
    3. Compilation Error
    4. 12
    5. None of these
Correct Option: A

Segmentation fault



Your comments will be displayed only after manual approval.