The program need to find mean of elements in columns which are divided by 3. And to print which colmn has the greater mean
Example
For matrix:
7 9 5
17 15 30
29 34 60
Program print: 0 12 45. The greater mean: 3 column.
I wrote this code and it prints 0 12 45 idk how to find which column has greater mean?
Code:
#include <stdio.h>
#define max 50
int main()
{int n,m,i,j,k,d,br=0,suma;
int a[max][max];
int b[max][max];
printf("Kolku redici i kolku koloni da imat matricite: \n");
scanf("%d \n %d \n", &n,&m);
for(i=0; i<m; i++)
{
for(j=0; j<n; j++)
{
scanf("%d", &a[i][j]);
}
}
printf("Prvata matrica izgleda vaka: \n");
for(i=0; i<m; i++)
{
for(j=0; j<n; j++)
{
printf("%d ", a[i][j]);
}
printf("\n");
}
for(i=0; i<n; i++)
{
suma=0;
for(j=0; j<n; j++)
{
if((a[j][i]%3)==0)
{
suma+= a[j][i];
br++;
}
}
if(br)
{
int b=suma/br;
printf("%d ", b);
br=0;
}
else {
int q=suma;
printf("%d \n", suma);}
}
}