Share
Explore BrainMass

C++ program to manipulate an array

Write a C++ program that will manipulate an array. It should handle up to 100 integer numbers. Write a separate function for each of the requirements mentioned below. Label the output appropriately.

Read in the values from attached file "array.dat" into the array. The last value is a 0 and is not one of the values to be used in any of the calculations mentioned below.

1. Print out all the values in the array with no more than 10 numbers per output line.
2. Print out the average of the numbers.
3. Print out how many numbers are larger than the average and how many are smaller than the average. Pass average as a parameter.
4. For every odd location in the array, subtract it from the previous even location and store results in the even location. Print out all values in the array.
5. Print out the average for the new array.
6. Find the smallest value in the array and print out its value and its location in the array.
7. Convert every negative number in the array to corresponding positive number. Print out the array.
8. Find the largest value in the array and print out its value and its location in the array.
9. Swap the first number in the array with the last number in the array. Print out the array.
10. Print out the average for the new array.

Attachments

Solution Preview

Please adjust the comments, and variables and functions names as per the naming convention you ...

Solution Summary

Solution makes use of macro NUMS_PER_LINE to control the count of numbers printed per line.

$2.19