
Memory Management

Quiz
•
Other
•
University
•
Medium
Kavinaya R
Used 1+ times
FREE Resource
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which header file is required for dynamic memory functions like malloc()?
<stdlib.h>
<malloc.h>
<stdio.h>
<memory.h>
Answer explanation
All dynamic memory functions like malloc(), calloc(), realloc(), and free() are declared in <stdlib.h>.
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which function is used to dynamically allocate memory in C?
alloc()
malloc()
memory()
free()
Answer explanation
malloc() allocates memory in bytes and returns a pointer to the first byte.
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will malloc() return if it fails to allocate memory?
-1
0
NULL
Error
Answer explanation
On failure, malloc() returns NULL
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which function is used to free dynamically allocated memory?
delete()
dispose()
free()
clear()
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of the following code?
int ptr = (int )malloc(sizeof(int));
*ptr = 5;
printf("%d", *ptr);
Compilation error
Address of ptr
5
Garbage Value
Answer explanation
Memory is allocated, value 5 is assigned and printed correctly.
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which function initializes memory to zero?
malloc()
calloc()
realloc()
free()
Answer explanation
calloc() allocates memory and sets all bytes to zero.
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the purpose of realloc()?
To allocate memory
To reassign memory
To change the size of previously allocated memory
To remove memory
Answer explanation
realloc() resizes a memory block that was previously allocated.
Create a free account and access millions of resources
Similar Resources on Wayground
15 questions
QUIZ 1 - CHAPTER 8 & 9

Quiz
•
12th Grade - University
10 questions
SCHEDULING ALGORITHMS

Quiz
•
University
15 questions
Exploring C: Strings, Arrays, Functions

Quiz
•
University
5 questions
C Pointer

Quiz
•
University
10 questions
FreeRTOS Heap Management Quiz

Quiz
•
University
13 questions
C Programming Concepts

Quiz
•
University
13 questions
Bachelor Cyber 1 - Cours 3

Quiz
•
University
10 questions
20EC204 Digital System Design Surprise Quiz

Quiz
•
University - Professi...
Popular Resources on Wayground
50 questions
Trivia 7/25

Quiz
•
12th Grade
11 questions
Standard Response Protocol

Quiz
•
6th - 8th Grade
11 questions
Negative Exponents

Quiz
•
7th - 8th Grade
12 questions
Exponent Expressions

Quiz
•
6th Grade
4 questions
Exit Ticket 7/29

Quiz
•
8th Grade
20 questions
Subject-Verb Agreement

Quiz
•
9th Grade
20 questions
One Step Equations All Operations

Quiz
•
6th - 7th Grade
18 questions
"A Quilt of a Country"

Quiz
•
9th Grade