Vidyalelo
C Programming · Q238

Pointer

Programming · C Programming · question 238

Q238

What will be the output of the following C code? #include int *f(); int main() int *p = f(); printf("%d ", *p); int *f() int *j = (int*)malloc(sizeof(int)); *j = 10; return j;

A.
10
Answer
B.
Compile time error
C.
Segmentation fault/runtime crash since pointer to local variable is returned
D.
Undefined behaviour

Answer: Option A

Solution

Answer: Option A
No explanation is given for this question Let's Discuss on Board