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 “<<sum<<endl;
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?
- All Prototypes, function declarations
- Function Definitions
- 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.
- 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;;
- 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)
- Calculate the sum of the two diagonals. Now print the absolute value of their difference. You do not need a function here
- 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.
- 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.
- Create a function called Transpose( int A, int numRows,int numCols) that will modify the array sent in by performing a transpose operation on the array. If numRows!=numCols then do nothing otherwise flip the array about the main diagonal (upper left to lower right).