i. Write a function averagecolumns that prints the averages of the ints for each
ID: 3655247 • Letter: I
Question
i. Write a function averagecolumns that prints the averages of the ints for each and every column of a 2-dim array.
PASS TWO-DIMENSIONAL ARRAY AND PRINT AS XXX.XX
Here is my code.....
#include "my.h"
void avgcols(int** table, int rows, int cols)
{
int i;
int k;
int sum;
float avg;
avg=(sum/cols);
printf("i. The various column averages are: ");
for(k=0; k<cols; k++)
{
sum=0;
for(i=0; i<rows; i++)
{
sum+=table[i][k];
}//end of nested for statement
printf("%6.2f", avg);
}//end of for statement
printf(" ");
}
this is what it prints when i run it using ./a.out data....
i. The various column averages are: 1.00 1.00 1.00
here is the data file for the array....
4 3 5 1 6 78 85 -13 8 -9 69 84 2 98
Explanation / Answer
Dim X As Integer, Y As Integer, Average As Double, Size As Integer, Sum As Integer Size = InputBox("Enter the number of random numbers to be generated between 20 and 100", "Input") X = 1: Y = 1 While XRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.