Memory Allocation MCQs

62 questionsC-ProgramPage 5 of 7

Practice free Memory Allocation multiple-choice questions with instant answer feedback and step-by-step solutions. Click an option to check yourself, reveal the full explanation, and work through all 62 questions — no login required.

Question 37hard
What will be the output of the following C code?
#include<stdio.h>
#include<stdlib.h>
void main()
{
    char *p = calloc(100, 1);
    p = "welcome";
    printf("%s\n", p);
}
Question 38easy
Which of the following is an example for non linear data type?
Question 39easy
Local variables are stored in an area called . . . . . . . .
Advertisement
Question 40medium
If the space in memory allocated by malloc is not sufficient, then an allocation fails and returns . . . . . . . .
Question 41hard
The following C code is an example of . . . . . . . .
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
main()
{
    char *p,*q;
    p=(char*)malloc(3*sizeof(char));
    q=p;
    strcpy(p,"hello");
    printf("p=%s",p);
    printf("q=%s",q);
    free(q);
    q=NULL;
    gets(p);
    gets(q);
    printf("%s",p);
    printf(“%s”,q);
}
Question 42medium
If malloc() and calloc() are not type casted, the default return type is . . . . . . . .
Advertisement
Question 43medium
Which of the following functions allocates multiple blocks of memory, each block of the same size?
Question 44medium
A condition where in memory is reserved dynamically but not accessible to any of the programs is called . . . . . . . .
Question 45medium
Which of the following header files must necessarily be included to use dynamic memory allocation functions?