Homework 7 - Working With Arrays

Add the following functionality to your lab7.cpp menu program.


Add menu option #6 Write and call a function that will accomplish the following. Declare a local character array that will hold 100 characters. Prompt the user to enter their first name into the array. Use cin. Display their name downwards. Function prototype: void getName(void); Sample output:
Menu item 6: Please enter your name here: Gordon G o r d o n done.
For those students who want to do more... Now that you learned how to read a whole sentence with the getline function, you can produce the following function if you like. Sample output:
Menu item 6: Enter a sentence here: Please buy Gordon some bit coins! Please buy Gordon some bit coins! done.
You may make this a separate menu item if you can make it work.
Add menu option #7 Write and call a function that will accomplish the following. Your new function declares a local integer array of size 10. Fill the array elements with random numbers from 0 to 100. Add all the array elements together. If the total is not 100, fill the array again. Continue trying until the total is exactly 100, then display the array. It may take a lot of tries for this to happen. Return the number of tries to your main function, and display it as shown in the sample output. Do not display the number of tries from within your function. Function prototype: int sumTo100(void); Sample output:
Menu item 7: Filling array with random values now... array total ----- ----- 9 9 12 21 3 24 22 46 5 51 9 60 0 60 0 60 13 73 27 100 number of tries: 670375
First column is array values. Second column is running total. Keep track of how many tries it takes.