Memory Allocation — Part 2 MCQs with Explanations
Practice high-yield Programming & Software Development MCQs on Memory Allocation — Part 2 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.
Questions
20
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
24 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
20
Verified Practice Questions
Interactive test mode with detailed academic worked solutions
Live Progress | 0/20 answered
✓ 0 correct
✗ 0 wrong
0% score
🎉 Set complete! All 20 questions answered.
Question 1 of 20
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Question 2 of 20
★ FPSC
★ PPSC
★ FPSC
★ PPSC
A condition where in memory is reserved dynamically but not accessible to any of the programs is called . . . . . . . .
Question 3 of 20
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following header files must necessarily be included to use dynamic memory allocation functions?
Question 4 of 20
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the error (if any) in the following C code? #include<stdio.h> #include<stdlib.h> #include<string.h> int main() { char *p; *p = (char)calloc(10); strcpy(p, "HELLO"); printf("%s", p); free(p); return 0; }
Question 5 of 20
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will happens if the statement free(a) is removed in the following C code? #include<stdio.h> #include<stdlib.h> main() { int *a; a=(int*)malloc(sizeof(int)); *a=100; printf("*a%d",*a); free(a); a=(int*)malloc(sizeof(int)); *a=200; printf("a%p",a); *a=200; printf("a%d",*a); }
Question 6 of 20
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In the function realloc(), if the new size of the memory block is larger than the old size, then the added memory . . . . . . . .
Question 7 of 20
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C code if it is executed on a 32 bit processor? #include<stdio.h> #include<stdlib.h> int main() { int *p; p = (int *)malloc(20); printf("%d\n", sizeof(p)); free(p); return 0; }
Question 8 of 20
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Garbage collector frees the programmer from worrying about . . . . . . . .
Question 9 of 20
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Suppose we have a one dimensional array, named 'x', which contains 10 integers. Which of the following is the correct way to allocate memory dynamically to the array 'x' using malloc()?
Question 10 of 20
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Queue data structure works on the principle of . . . . . . . .
Question 11 of 20
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is an example of static memory allocation?
Question 12 of 20
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C code? (Given that the size of array is 4 and new size of array is 5) #include<stdio.h> #include<stdlib.h> main() { int *p,i,a,b; printf("Enter size of array"); scanf("%d",&a); p=(int*)malloc(a*sizeof(int)); for(i=0;i<a;i++) printf("%d\n",i); printf("Enter new size of array"); scanf("%d",&b); realloc(p,b); for(i=0;i<b;i++) printf("%d\n",i); free(p); }
Question 13 of 20
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The type of linked list in which the node does not contain any pointer or reference to the previous node is . . . . . . . .
Question 14 of 20
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In the function malloc(), each byte of allocated space is initialized to zero.
Question 15 of 20
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The number of arguments taken as input which allocating memory dynamically using malloc() is . . . . . . . .
Question 16 of 20
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Choose the statement which is incorrect with respect to dynamic memory allocation.
Question 17 of 20
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Pick out the correct statement with respect to the heap.
Question 18 of 20
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The size of both stack and heap remains the same during run time.
Question 19 of 20
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The advantage of using linked lists over arrays is that . . . . . . . .
Question 20 of 20
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The incorrect statement with respect to dangling pointers is . . . . . . . .
✓ Link copied to clipboard
Continue Your Practice
Next Practice Set → Advance Html — Part 1
Master the next curriculum module with 40 exam-standard MCQs.
💡 Examiner's Advisory for Programming & Software Development
In competitive commission exams (FPSC, PPSC, KPPSC, SPSC, CSS, PMS), questions are frequently phrased with distractor options designed to catch rote learners. Whenever you answer an MCQ, read the Detailed Academic Explanation and Conceptual Anchor to understand why the remaining options are incorrect.