I am having some problems with writing a 2d array, then displaying it, and then showing the sum of all of the elements. A major part of this problem is that i nave to write three seperate functions to achieve this. it is supposed to do this:
For this exercise you will use both arrays and functions! Write a program called matrix.c that adds every element in a 2-dimensional array (matrix). Your matrix will be 5 x 5 (5 rows and 5 columns). The requirement is to use nested "for loops" in your program.
You must develop 3 functions within this program: One to read user input; another to display the 2-D array; and a third that returns the total of all elements in the 2-D array. The 3rd function should NOT print the value, rather the value should be returned from the function to main, and main will display the result. Your function prototype might look like this: int addArray( int arr[ ][ COLSIZE ] );
Make the program flexible so that you can easily change the size of the table. A suggestion for doing so is to use a define, for example: #define rowSIZE 5.
Input
5 x 5 matrixOutput
Output the matrixOutput the matrix sum
Below is a sample of expected output (my input is in blue - this is to illustrate only, yours will not be blue):
Please enter enter data for a 5 by 5 array:
1 2 3 …