Howdy,

I need to take as input bi-dimensional array and summarize its columns (each column separately) & rows (each row separately).

This is what I wrote so far:

Code:

#include<stdio.h>
#define ROW 2
#define COL 2
void sumrz(int a[][COL],int *sum_row, int *sum_col);
void main ()
{
int a[ROW][COL],i,j,*sum_row,*sum_col;
for (i=0;i<ROW ;i++)
for (j=0;j<COL;j++)
scanf ("%d", &a[i][j]);
sumrz(a,sum_col,sum_row);
printf ("array is: \n");
for (i=0;i<ROW;i++)
for(j=0;j<COL;j++)
{
printf("%d",a[i][j]);
printf ("\n");
}
}
void sumrz(int a[][COL],int *sum_row, int *sum_col)
{
int i,j;
for (i=0;i<ROW;i++)
*sum_row =0;
for(j=0;j<COL;j++)
*sum_row+=a[i][j];
printf ("row sum is %d\n", *sum_row);
for (j=0;j<COL;j++)
*sum_col=0;
for (i=0;i<ROW;i++)
*sum_col+=a[i][j];
printf ("column sum is %d\n", *sum_col);
}

It’s clear to me I misuse pointers. Will you help me right it correctly? Are ther any others false? Progarm does't give output.

Thanx!

Ronen