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 * sizeof(int*));
return 0;
}
Pick an option to check yourself, or open the answer below.
Show answer & explanation
Correct answer: D. free(p);
Explanation
Memory obtained with malloc is released with free(p).More Programming Languages and Computer Graphics questions
- The clipping process in computer graphics is used for
- Consider the rectangle with vertices (0, 0), (0, 2), (3, 0), (3, 2). It is scaled by 2 along the x-axis and 3 along the y-axis. The new coo…
- Which of the following 2-D transformations is used to resize a 2-dimensional object?
- What is the output of the following code?main() { static float a[] = {13.24, 1.5, 4.5, 5.4, 3.5}; float *j, *k; j = a; k = a + 4; j = j * 2…
- Which of the following is NOT an object-oriented programming language?
- What is the output of the following C program?#include <stdio.h> int main(void) { int x, *p; x = 30; p = x; printf("%d", *p); return 0; }