Calculate and print the sum of every value in the array


Program 1: 2D Array manipulation

This first program concerns itself with 2D Arrays and Functions with array parameters. You are to create program in visual studio c++ 15 or 17. This compiler includes the new C++11 features that were defined in 2011 standard committee. You are to create a statically allocated 2D integer array called A of size 10 by 10. You are then requested to initialize this array, row by row using as looping construct. The first row contains the values 1 thru 10, the second row 11 thru 20, and so on until the last row is 91 thru 100. You are now requested to perform the following operations one after another in the order indicated. Document each section appropriately. Also if you are printing something like a sum then your output should include that info in the print. e.g. cout<<"The sum of the top row is "<

Program this problem incrementally. IE get step 1 to work then step 2 to work and so on. The form of your program should be as follows. This is the usual practice preached by SE's. Can you think of reasons this structure is often requested?

1. #includes
2. All Prototypes, function declarations
3. Main
4. Function Definitions

operations are

1. Dump the array. Note Dump() is the only function that is allowed to have cout's. e.g. no standard out output for the other functions. Dump means to print out the array a row at a time.

2. Print out the 4th row and the 7th column. This is not in a function. Just write inline code to do this. You can have cout's in main here;;

3. Calculate and print the sum of every value in the array using a function that you write called int Sum( int A[][], int numRows,int numCols)

4. Calculate the sum of the two diagonals. Now print the absolute value of their difference. You do not need a function here

5. Create a function called int BorderSum( int A[][], int numRows,int numCols) that returns the sum of the values that occur on all four sides of the array, e.g. the border. Call this function and print out the returned value.

6. Create a function called int InsideSum( int A[][], int numRows,int numCols) that returns the sum of the values on the inside of the array , e.g. sum of everything BUT the border. THINK! This is now easy.

7. Create a function called Transpose( int A[][], int numRows,int numCols) that will modify the array sent in by performing a transposeoperation on the array. If numRows!=numCols then do nothing otherwise flip the array about the main diagonal (upper left to lower right).

Print the above and combine it together with your source and output. Create two outputs, one with a 3 by 3 matrix and one with a 10 by 10 matrix. Staple together and hand in.

Solution Preview :

Prepared by a verified Expert
Data Structure & Algorithms: Calculate and print the sum of every value in the array
Reference No:- TGS02446446

Now Priced at $120 (50% Discount)

Recommended (94%)

Rated (4.6/5)