Skip to main content

Memory Allocation — Part 1 MCQs with Explanations

Practice high-yield Programming & Software Development MCQs on Memory Allocation — Part 1 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.

Questions
40
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
48 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
40

Verified Practice Questions

Interactive test mode with detailed academic worked solutions

Live Progress | 0/40 answered
✓ 0 correct ✗ 0 wrong 0% score
Question 1 of 40
★ FPSC ★ PPSC

The number of arguments for realloc() function is/are:

Question 2 of 40
★ FPSC ★ PPSC

In C, which header file should be included to use dynamic memory allocation functions?

Question 3 of 40
★ FPSC ★ PPSC

What is the purpose of the 'malloc' function in C?

Question 4 of 40
★ FPSC ★ PPSC

Which function is used to allocate an array of elements in C?

Question 5 of 40
★ FPSC ★ PPSC

What does the 'calloc' function in C do?

Question 6 of 40
★ FPSC ★ PPSC

Which function is used to change the size of an allocated block of memory in C?

Question 7 of 40
★ FPSC ★ PPSC

What is the return value of the 'malloc' function if it fails to allocate memory?

Question 8 of 40
★ FPSC ★ PPSC

How do you release dynamically allocated memory in C?

Question 9 of 40
★ FPSC ★ PPSC

What is the purpose of the 'memset' function in C?

Question 10 of 40
★ FPSC ★ PPSC

Which function is used to copy a block of memory in C?

Question 11 of 40
★ FPSC ★ PPSC

What is the purpose of the 'free' function in C?

Question 12 of 40
★ FPSC ★ PPSC

How do you check if the 'malloc' function has successfully allocated memory in C?

Question 13 of 40
★ FPSC ★ PPSC

Which function is used to return the number of bytes allocated by 'malloc'?

Question 14 of 40
★ FPSC ★ PPSC

What is the return value of the 'realloc' function if it fails to reallocate memory?

Question 15 of 40
★ FPSC ★ PPSC

What does the 'sizeof' operator in C return for a dynamically allocated array?

Question 16 of 40
★ FPSC ★ PPSC

Which function is used to allocate memory for an array of character strings in C?

Question 17 of 40
★ FPSC ★ PPSC

What is a segmentation fault in C?

Question 18 of 40
★ FPSC ★ PPSC

How do you check if the 'realloc' function has successfully reallocated memory in C?

Question 19 of 40
★ FPSC ★ PPSC

Which function is used to free allocated memory but does not remove the pointer in C?

Question 20 of 40
★ FPSC ★ PPSC

What is the maximum number of bytes that can be allocated using 'malloc' in C?

Question 21 of 40
★ FPSC ★ PPSC

What is the difference between 'malloc' and 'calloc' in C?

Question 22 of 40
★ FPSC ★ PPSC

In C, which function is used to allocate memory from the stack?

Question 23 of 40
★ FPSC ★ PPSC

What happens if you attempt to free the same block of memory twice in C?

Question 24 of 40
★ FPSC ★ PPSC

What is the primary advantage of using dynamic memory allocation in C?

Question 25 of 40
★ FPSC ★ PPSC

Which function is used to allocate memory for a structure in C?

Question 26 of 40
★ FPSC ★ PPSC

What is the difference between 'free' and 'delete' in C?

Question 27 of 40
★ FPSC ★ PPSC

Which function is used to release all dynamically allocated memory in C?

Question 28 of 40
★ FPSC ★ PPSC

In C, what is the purpose of the 'realloc' function?

Question 29 of 40
★ FPSC ★ PPSC

What is a memory fragment in C?

Question 30 of 40
★ FPSC ★ PPSC

With every use of a memory allocation function, what function should be used to release allocated memory, which is no longer needed?

Question 31 of 40
★ FPSC ★ PPSC

Array is preferred over linked list for the implementation of . . . . . . . .

Question 32 of 40
★ FPSC ★ PPSC

The free() function frees the memory state pointed to by a pointer and returns . . . . . . . .

Question 33 of 40
★ FPSC ★ PPSC

When the pointer is NULL, then the function realloc is equivalent to the function . . . . . . . .

Question 34 of 40
★ FPSC ★ PPSC

What will be the output of the following C code if the input entered as first and second number is 5 and 6 respectively? #include<stdio.h> #include<stdlib.h> main() { int *p; p=(int*)calloc(3*sizeof(int)); printf("Enter first number\n"); scanf("%d",p); printf("Enter second number\n"); scanf("%d",p+2); printf("%d%d",*p,*(p+2)); free(p); }

Question 35 of 40
★ FPSC ★ PPSC

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 36 of 40
★ FPSC ★ PPSC

Which of the following is an example for non linear data type?

Question 37 of 40
★ FPSC ★ PPSC

Local variables are stored in an area called . . . . . . . .

Question 38 of 40
★ FPSC ★ PPSC

If the space in memory allocated by malloc is not sufficient, then an allocation fails and returns . . . . . . . .

Question 39 of 40
★ FPSC ★ PPSC

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 40 of 40
★ FPSC ★ PPSC

If malloc() and calloc() are not type casted, the default return type is . . . . . . . .

✓ Link copied to clipboard
Continue Your Practice

Advance Html — Part 1

Master the next curriculum module with 40 exam-standard MCQs.

Next Practice Set →

💡 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.

More Modules in Programming & Software Development

View All →
📚

Study Guides

Topic summaries and syllabus breakdown

Explore Guides →
🎯

Complete Library

Search through 78,000+ verified MCQs

Browse Library →
📱

Mobile App

Offline mock tests and instant bookmarks

Get Mobile App →