Purchase Solution

C++ program to manipulate an array

Not what you're looking for?

Ask Custom Question

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
Purchase this Solution

Solution Summary

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

Solution Preview

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

Purchase this Solution


Free BrainMass Quizzes
Javscript Basics

Quiz on basics of javascript programming language.

Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.

Word 2010: Tables

Have you never worked with Tables in Word 2010? Maybe it has been a while since you have used a Table in Word and you need to brush up on your skills. Several keywords and popular options are discussed as you go through this quiz.

Java loops

This quiz checks your knowledge of for and while loops in Java. For and while loops are essential building blocks for all Java programs. Having a solid understanding of these constructs is critical for success in programming Java.

Basic Computer Terms

We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.