Govt Exams
Double free is undefined behavior and can cause program crash or corruption. After first free(), the pointer should not be used.
Allocating without freeing causes memory leak, where allocated memory is not returned to the system, eventually exhausting heap.
2D arrays are allocated as array of pointers, where each row pointer points to a dynamically allocated array.
calloc(5, sizeof(int)) allocates memory for 5 integers and initializes all to zero.
calloc() allocates memory and initializes all bytes to zero, while malloc() leaves the allocated memory uninitialized.
free() is used to deallocate memory that was previously allocated using malloc(), calloc(), or realloc().
stdlib.h contains declarations for malloc(), calloc(), realloc(), and free() functions.
Without freeing, allocated memory accumulates until system runs out of heap space, causing allocation failure or crash.
Stack allocation (option A) will cause stack overflow. Dynamic allocation on heap is required for large data.
Dangling pointer points to memory that has been freed. Accessing it causes undefined behavior.