-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDS_4.c
37 lines (34 loc) · 761 Bytes
/
DS_4.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <stdio.h>
#define SIZE 3
int main()
{
int A[SIZE][SIZE];
int r, c, sum = 0;
printf("Enter elements in matrix of size %dx%d= \n", SIZE, SIZE);
for(r=0; r<SIZE; r++) //input matrix
{
for(c=0; c<SIZE; c++)
{
scanf("%d", &A[r][c]);
}
}
for(r=0; r<SIZE; r++) //sum of row
{
sum = 0;
for(c=0; c<SIZE; c++)
{
sum = sum+A[r][c];
}
printf("Sum of elements of Row %d = %d\n", r+1, sum);
}
for(r=0; r<SIZE; r++) //sum of column
{
sum = 0;
for(c=0; c<SIZE; c++)
{
sum = sum+A[c][r];
}
printf("Sum of elements of Column %d = %d\n", r+1, sum);
}
return 0;
}