-
Notifications
You must be signed in to change notification settings - Fork 0
/
sum_of_row.c
61 lines (43 loc) · 996 Bytes
/
sum_of_row.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//sum of row and column.
#include<stdio.h>
int main()
{
int store[3][3],i,j,sum=0;
//input.
for ( i = 0; i < 3; i++)
{
for ( j = 0; j < 3; j++)
{
printf("Enter the number: ");
scanf("%d",&store[i][j]);
}
}
printf("\n2D ARRAY:\n");
for ( i = 0; i < 3; i++)
{
printf("\n");
for ( j = 0; j < 3; j++)
{
printf("%d\t",store[i][j]);
}
}
//operation.
for ( i = 0; i < 3; i++)
{
for ( j = 0; j < 3; j++)
{
sum=sum+store[i][j]; //row.
}
printf("\nSum Of Row Number %d: %d\n",i+1,sum);
}
sum=0; //resetting the value for column.
for ( i = 0; i < 3; i++)
{
for ( j = 0; j < 3; j++)
{
sum=sum+store[j][i]; //column.
}
printf("\nSum Of Column Number %d: %d\n",i+1,sum);
}
return 0;
}