Let’s revisit dynamic memory allocation with
a peek into program organization, and steps on starting the project -
along with a sample grocery list program.
Create a program that asks for user input and stores it in an array. At the end of the program, print all of the numbers entered by the user.
Create a struct for school supplies that contains the number of pencils, pens, papers, computers, and books. Use constructor and destructor functions to allocate the structure. Prompt the user for the number of supplies previously listed.
Challenge Create a program that asks to input their grocery list, record all of the user’s inputs and operations in a tape file. The program will function in the steps below:
|new||enter new item, go to step 2|
|total||print list of items|
|last||print the previous entered item and amount, and prompt to enter ‘last’ again|
Prompt for, and accept the item to be added to the list. Can clear to go to step 1 or quit to exit the program.
Prompt for, and accept, an integer number of the amount you will be buying for the previous item entered. Can clear to go to step 1 or quit to exit the program.
Prompt for, and accept, a floating-point number of the previous item’s price entered. Can clear to go to step 1 or quit to exit the program.
Return to step 1.