Dynamic Memory Exercises
🔖 Background Information
Dynamic memory allocation is a technique where we can allocate, utilize, and eventually return blocks of memory on the heap. This gives us the flexibility to create data structures that can shrink and grow throughout the life of our program.
🎯 Problem Statement
Complete the following exercises:
- Write a program to dynamically allocate three variables: an integer, a character, and a string. Assign a value to each of them after they have been allocated on the heap.
- Write a program to dynamically allocate an array of ten integers, and initialize its elements with the numbers 1 - 10.
- Write a program to dynamically create an object of a class using the
new
operator. You can create your own custom class for this exercise. - Write a program to dynamically create an array of objects using the new operator. You can use the custom class that you created in the previous exercise here.
- Write a program to dynamically allocate a two-dimensional array of float values. Initialize its elements with zeros.
✅ Acceptance Criteria
- You should write a short program for each of the questions listed in the Problem Statement.
📋 Dev Notes
N/A
🖥️ Example Output
N/A
📘 Works Cited
N/A