GATE Computer Science (CS) 2017 Shift 1 Solved Paper
© examsiri.com
Question : 23 of 65
Marks:
+1,
-0
Consider the following C code:
The code suffers from which one of the following problems:
#include <stdio.h>
int *assignval(int *x, int val) {
*x = val;
return x;
}
void main () {
int *x = malloc(sizeof(int));
if (NULL == x) return;
x = assignval (x, 0);
if (x) {
x = (int *) malloc (sizeof(int));
if(NULL == x) return;
x = assignval (x, 10);
}
printf(“%d\n”, *x);
free(x);
}The code suffers from which one of the following problems:
Go to Question: