C++ Dynamic Memory Allocation Exercises with Solutions
This resource offers a total of 50 C++ Dynamic Memory Allocation problems for practice. It includes 10 main exercises, each accompanied by solutions, detailed explanations, and four related problems.
[An Editor is available at the bottom of the page to write and execute the scripts.]
1. Dynamically Allocate Basic Types
Write a C++ program to dynamically allocate an integer, a character and a string and assign a value to them.
2. Dynamically Allocate an Array of Integers and Strings
Write a C++ program to dynamically allocate an array of integers and strings and initialize its elements.
3. Dynamically Allocate Two Two-Dimensional Arrays of Floating Values and Strings
Write a C++ program to dynamically allocate two two-dimensional arrays of floating values and strings. Initialize its elements.
4. Dynamically Allocate Memory for a Character and a String with User Input
Write a C++ program to dynamically allocate memory for a character and a string. Input a character and a string from the user.
5. Dynamically Create an Object of a Class Using New
Write a C++ program to dynamically create an object of a class using the new operator.
6. Dynamically Create an Array of Objects Using New
Write a C++ program to dynamically create an array of objects using the new operator.
7. Dynamically Allocate Memory for a Structure and Input Its Members
Write a C++ program to dynamically allocate memory for a structure and input its members from the user.
8. Dynamically Allocate Memory for a Linked List and Perform Basic Operations
Write a C++ program to dynamically allocate memory for a linked list and perform basic operations like insert and delete node(s).
9. Dynamically Allocate Memory for a Stack and Implement Push/Pop
Write a C++ program to dynamically allocate memory for a stack data structure. Implement push and pop operations on this stack.
10. Dynamically Allocate Memory for a Queue and Implement Enqueue/Dequeue
Write a C++ program to dynamically allocate memory for a queue data structure. Implement enqueue and dequeue operations on this queue.
CPP Code Editor:
More to Come !
Do not submit any solution of the above exercises at here, if you want to contribute go to the appropriate exercise page.