Skip to content

UGC NET CS 2023Programming Languages and Computer Graphics › Programming in CVerified

UGC NET CS 2023 PYQ: How will you free the memory allocated by the following program? #include <stdio.h> #include <stdlib.h>…

How will you free the memory allocated by the following program?

#include <stdio.h>
#include <stdlib.h>
#define MAXROW 3
#define MAXCOL 4
int main ( )
{
int ** p, i, j;
p= (int **) malloc (MAXROW * size of (int*));
return 0 ;
}
  1. A
    memfree $\text{(int p)}$;
  2. B
    dealloc $\text{(p)}$;
  3. C
    malloc $(\mathrm{p}, 0)$;
  4. D
    free $\text{(p)}$:
    Correct answer

Answer

(D) free $\text{(p)}$:

Approach

Release heap memory with the standard C function paired with malloc.

Reviewed by UGC IQ Editorial Team.