Thread: compute the average of each row and column

1. compute the average of each row and column

i need to create a function to the program i've written which takes the two-dimensional array and returns an array "r" (of length 4) and "c" (of length 3). This function should computer the average values of each row and column, then return r and c to main program. both array need to be double precision. Here is the code of the main function, it just created a two-dimensional array of size 4x3 and is initialized to the sum of x, the row, and column values:

Code:
```# include <stdio.h>

void mavg(int m[][3]);

int main(void)
{
int x;
int i, j;
int m[4][3];

/* Part 1 */
printf("Enter an integer x: ");
scanf("%d", &x);

/* Part 2 */
for(i=0; i<4; i++){
for(j=0; j<3; j++){
m[i][j] = i+j+x;
printf(" %d", m[i][j]);
}
printf("\n");
}

mavg(m);

return 0;
}

void mavg(int m[][3])
{
int r[4];
int c[3];

int sum, row, x, y, avg;

sum = 0;
row = 0;

}```

2. 1. Go read the thing on the forum that said << !! Posting Code? Read this First !! >>
2. Come back to your first post and press Edit.
3. Find the start of your code and right before it, add: [code]
4. Find the end of your code and right after it, add: [/code]
5. Press save.
6. Go read the homework policy sticky as well.

Quzah.

3. When you edit it to fix the code with code tags, add in what it is that has you stumped at the moment.

Posts without questions, don't get many answers - and Welcome to the forum, Rasiegel!

4. i need to figure out how to pass an array to a function and how to make a for statement to add the rows and columns thanks

5. This should get you started on loops: Cprogramming.com Tutorial: Loops
As for how to pass an array:
Code:
```void foo( type array[], int size );
...
type array[ 4 ];
...
foo( array, 4 );```
That should give you the general idea.

Quzah.