int main ()
{
int a[3][3],i,j,r_sum,c_sum;
printf("Enter values:\n");
for(i=0;i<3;i++) //input
{
for(j=0;j<3;j++)
{
scanf("%d",&a[i][j]);
}
}
for(i=0;i<3;i++) //calculatoin & output
{
r_sum=0;
c_sum=0;
for(j=0;j<3;j++)
{
r_sum=r_sum+a[i][j];
}
for(j=0;j<3;j++)
{
c_sum=c_sum+a[j][i];
}
printf("Row %d sum is: %d\n",i+1,r_sum);
printf("Column %d sum is: %d\n\n",i+1,c_sum);
}
return 0;
}
No comments:
Post a Comment