Addrows: Arr I J Rows Columns Rows Rows I Rows Sum Columns Columns J Columns Sum Sum Arr Rows Columns %D %D Rows Sum

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

#include<stdio.

h>

void addRows(int arr[10][10], int i, int j)


{
int rows, columns;
for(rows = 0; rows < i; rows++)
{
int Sum = 0;
for(columns = 0; columns < j; columns++)
{
Sum = Sum + arr[rows][columns];
}
printf("The Sum of Elements of %d Rows in a Matrix = %d \n",rows,Sum
);
}
}
int main()
{
int i, j, rows, columns, a[10][10];

printf("Please Enter Number of rows and columns : ");


scanf("%d %d", &i, &j);

printf("Please Enter the Matrix Row and Column Elements \n");


for(rows = 0; rows < i; rows++)
{
for(columns = 0; columns < j; columns++)
{
scanf("%d", &a[rows][columns]);
}
}

addRows(a, i, j);

return 0;
}
/* #include <stdio.h>
void main ()
{

int arr[10][10];
int i, j, m, n, sum = 0;

printf("Enter the rows and columns of the matrix\n");


scanf("%d %d", &m, &n);

printf("Enter the %d elements of the %d X %d matrix\n",m*n,m,n);


for (i = 0; i < m; ++i)
{
for (j = 0; j < n; ++j)
{
scanf("%d", &arr[i][j]);
}
}

for (i = 0; i < m; ++i)


{
for (j = 0; j < n; ++j)
{
sum = sum + arr[i][j] ;
}

printf("Sum of the %d row is = %d\n", i, sum);


sum = 0;

}*/

You might also like