New course! Every coder should learn Generative AI!
Try a free lesson0
//assuming that max. rows and columns are 10,10 respectively
void RowColSum (float A[10][10],int r,int c)
{ int i,j; float RS[RS], CS[10];
//find row sum
for (i=0; i <r; i++)
{ RS [i]=0;
for (j=0 ; j <c ; j++)
RS [i]+=A[i][j];
}
//find column sum
for (j=0 ; j <c ; j++)
{ CS [j]=0;
for (i=0 ; i <r ; i++)
CS [j]+=A [i][j];
}
//Display 2-D array with roes and columns
for ( i=0 ; i <r ; i++)
{ for ( j=0 ; j <c ; j++)
cout <<A[i][j]<<'t';
cout <<RS [i]<<endl;
}
for (j=0 ; j <c ; j++)
cout <<CS [j]<<'\t' ;
cout <<endl;
}
Its a bit lengthy but easy to understand, just concentrate and understand
HOPE this help you
PEACE \/