Question: In C#, write a program with the following functions. Write a function that, given a 2D array, returns a 1D array of the sum of

In C#, write a program with the following functions.

Write a function that, given a 2D array, returns a 1D array of the sum of the rows in the 2D array.

 static int[] sumOfRows ( int[,] m, int rows, int cols ) { . . . } 

Write a function that, given a 2D array, returns a 1D array of the sum of the columns in the 2D array.

 static int[] sumOfCols ( int[,] m, int rows, int cols ) { . . . } 

Write a function that, given a 2D array, returns the mean (average) of all elements in the array.

 static double mean ( int[,] m, int rows, int cols ) { . . . } 

Often 2D images are simply stored as 1D arrays. Write a function that, given a 1D array (representing an 2D image of size w and h), returns the mean (average) of all elements in the array.

 static double mean1D ( int[] m, int rows, int cols ) { . . . } 

Write a function that, given a 2D array, returns the trace of the array. Note that trace is only defined for square m so your functions should check and output a message for non-square m.

 static int trace ( int[,] m, int rows, int cols ) { . . . } 

Use the following as framework for your code. Save it in a file called HelperFunctions.cs. Do not put main in this file. Don't forget to properly doxygen-ate the file, class, and every method.

using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Start { public class HelperFunctions { public static int[] sumOfRows ( int[,] m, int rows, int cols ) { return null; } public static int[] sumOfCols ( int[,] m, int rows, int cols ) { return null; } public static double mean ( int[,] m, int rows, int cols ) { return 0; } public static double mean1D ( int[] m, int rows, int cols ) { return 0; } public static int trace ( int[,] m, int rows, int cols ) { return 0; } } } 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!