Question: 2. Write a program , change.cpp , that uses a 10 element array. It first places the numbers 1 through 10 in the array. It

2. Write a program, change.cpp, that uses a 10 element array. It first places the numbers 1 through 10 in the array. It then prints the array. The user is then repeatedly prompted for an index value and an integer to place in the array. After each input, the given value is place at the given index in the array and the array is printed. The program should stop when the user enters an illegal index value (outside the range of 0 to 9).

You are required to write functions to initialize and print the array. You may write other functions if you like.

A sample run might be (user input in bold):

The array is:

1 2 3 4 5 6 7 8 9 10

Enter an index: 4

Enter a number: 12

The array is:

1 2 3 4 12 6 7 8 9 10

Enter an index: 8

Enter a number: 77

The array is:

1 2 3 4 12 6 7 8 77 10

Enter an index: 44

Enter a number: 3

All Done!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!