adplus-dvertising
frame-decoration

Question

What is the output of this program?
#include <stdio.h>
void main()
{
   int *ptr = (int *)malloc(sizeof(int));
   *ptr = 10;
   free(ptr);
   p = 5;
   printf("%d", ptr);
}

a.

Compilation error

b.

5

c.

0

d.

Garbage value

Posted under C Programming

Answer: (b).5

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the output of this program?