Error: fun() returns a pointer const character which cannot be modified
D -
No error
3-
Which header file should be included to use functions like malloc() and calloc()?
A -
memory.h
B -
stdlib.h
C -
string.h
D -
dos.h
4-
What function should be used to free the memory allocated by calloc() ?
A -
dealloc();
B -
malloc(variable_name, 0)
C -
free();
D -
memalloc(variable_name, 0)
5-
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;
}
A -
memfree(int p);
B -
dealloc(p);
C -
malloc(p, 0);
D -
free(p);
6-
Specify the 2 library functions to dynamically allocate memory?
A -
malloc() and memalloc()
B -
alloc() and memalloc()
C -
malloc() and calloc()
D -
memalloc() and faralloc()
7-
What will be the output of the program?
#include<stdio.h>
#include<stdlib.h>
int main()
{
int *p;
p = (int *)malloc(20); /* Assume p has address of 1314 */
free(p);
printf("%u", p);
return 0;
}
A -
1314
B -
Garbage value
C -
1316
D -
Random address
8-
What will be the output of the program (16-bit platform)?
#include<stdio.h>
#include<stdlib.h>
int main()
{
int *p;
p = (int *)malloc(20);
printf("%d\n", sizeof(p));
free(p);
return 0;
}
#include<stdio.h>
#include<stdlib.h>
int main()
{
union test
{
int i;
float f;
char c;
};
union test *t;
t = (union test *)malloc(sizeof(union test));
t->f = 10.10f;
printf("%f", t->f);
return 0;
}