Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C programming Write a function definition for a user-defined function that calcu

ID: 3779578 • Letter: C

Question

C programming

Write a function definition for a user-defined function that calculates the (floating-point double) mean of a specified column in a 2-D array that has NROWS rows and NCOLS columns. (NROWS and NCOLS are pre-defined symbolic constants) The parameters should be the double array and the desired column, as specified in the following function prototype: double col_mean(double x[NROWS, NCOLS], int col); Same as #3, but calculating the standard deviation rather than the mean. sigma = Squareroot 1/N sigma_i=1^N (x_i - x_avg)^2

Explanation / Answer

Here is the code for the first problem:

double col_mean(double x[][NCOLS], int col)
{
double mean = 0;
for(int i = 0; i < NROWS; i++)
mean += x[i][col];
return mean / NROWS;
}