---Sujal---

Background

Static memory allocation

---Pranav---

Dynamic Memory Allocation

---Dhruv---

Heap segment

Unlike the stack where the memory is allocated or deallocated in a defined contiguous order, the heap is an area of memory, where memory is allocated and deallocated without any order, or randomly.

```c int main() { int i, n; printf("Enter the number of integers: "); scanf("%d", &n);

int ptr = (int )malloc(n*sizeof(int));

if (ptr == NULL) { printf("Memory not available."); exit(1); }

for (i = 0; i < n; i++) { printf("Enter an integer: "); scanf("%d", ptr + i); }

for (i = 0; i < n; i++) printf("%d", *(ptr + i)); return 0;
} ```

---Pranav--- ---Sujal---

End Slide

The End.