-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSum_RCsum_Transpose.cpp
77 lines (77 loc) · 1.39 KB
/
Sum_RCsum_Transpose.cpp
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include<iostream>
using namespace std;
int main()
{
int m, n, sumr = 0, sumc = 0, fsum = 0;
int arr[100][100];
cout << "Enter the rows : ";
cin >> m;
cout << "Enter the cloumns : ";
cin >> n;
for (int i = 0; i < m; i++)
{
int j;
for (j = 0; j < n; j++)
{
cin >> arr[i][j];
}
}
cout << "The Matrice is : " << endl;
for (int i = 0; i < m; i++)
{
int j;
for (j = 0; j < n; j++)
{
cout << arr[i][j] << " ";
}
cout << endl;
}
for (int i = 0; i < m; i++)
{
int j;
for (j = 0; j < n; j++)
{
sumr +=arr[i][j];
}
}
cout << "Sum of the elements of Matrice is : " <<sumr<<endl;
sumr = 0;
cout << endl;
cout << "Sum of Rows : " << endl;
for (int i = 0; i < m; i++)
{
int j;
for (j = 0; j < n; j++)
{
sumr += arr[i][j];
}
fsum = sumr - sumc;
cout << "Element of row " << i + 1 << " sum is : " << fsum<<endl;
sumr=sumc;
}
cout << endl;
cout << "Sum of Columns : " << endl;
for (int i = 0; i < n; i++)
{
int j;
for (j = 0; j < m; j++)
{
sumr += arr[j][i];
}
fsum = sumr - sumc;
cout << "Element of Column " << i + 1 << " sum is : " << fsum << endl;
sumr = sumc;
}
cout << endl;
cout << "Transpose of Matric : " << endl;
for (int i = 0; i < n; i++)
{
int j;
for (j = 0; j < m; j++)
{
cout << arr[j][i] << " ";
}
cout << endl;
}
return 0;
}