C Programming – Day 11 | Dynamic Memory Allocation: malloc, calloc, realloc, free, C Explained
DYNAMIC MEMORY ALLOCATION IN C
DAY - 11
✅ Let’s move to Day-11 — Dynamic Memory Allocation in C 🚀
📍 Day-11 — Dynamic Memory Allocation in C
Today we will learn:
✅ What is Dynamic Memory Allocation
✅ Difference between static & dynamic memory
✅ malloc(), calloc(), realloc(), free()
✅ Task + Quiz
✅ 1️⃣ What is Dynamic Memory Allocation?
📌 Memory is allocated at runtime instead of compile time.
📌 Useful when you don’t know array size in advance.
-
Static memory → compile-time, fixed size
-
Dynamic memory → runtime, flexible
✅ 2️⃣ malloc() — Memory Allocation
✅ 3️⃣ calloc() — Contiguous Allocation
✅ Difference: calloc initializes memory to zero, malloc doesn’t
✅ 4️⃣ realloc() — Resize Memory
✅ Useful if you want to increase/decrease array size at runtime
✅ 5️⃣ free() — Free Memory
✅ Task-11
Write a program:
✔ Input number of elements from user
✔ Allocate memory using malloc()
✔ Input elements and print them
✔ Reallocate memory to add 2 more elements using realloc()
✔ Print updated array
Example Output:
📝 Quick Quiz — Day-11
Reply like: 1B, 2A, 3C
1️⃣ Function to allocate memory dynamically:
A) free()
B) malloc()
C) scanf()
2️⃣ calloc() initializes memory to:
A) Garbage value
B) 0
C) 1
3️⃣ Function to free allocated memory:
A) release()
B) delete()
C) free()
📌 Reminder:
Send your Task-11 Code and Day-11 Quiz Answers when ready!
Then we will proceed to Day-12: Final Projects & Revision 🎯

No comments
Thank You For Visit My Website.
I Will Contact As Soon As Possible.