-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathRowwiseandColSumProblem2Darray.cpp
More file actions
54 lines (44 loc) · 961 Bytes
/
Copy pathRowwiseandColSumProblem2Darray.cpp
File metadata and controls
54 lines (44 loc) · 961 Bytes
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
#include<iostream>
using namespace std;
void printRowSum(int arr[][3] , int row ,int col){
cout<<"Printing Sum row wise-->"<<endl;
for(int row=0; row<3; row++){
int sum=0;
for(int col=0; col<3; col++){
sum += arr[row][col];
}
cout<<sum<<" ";
}
cout<<endl;
}
void printColSum(int arr[][3] , int row ,int col){
cout<<"Printing Sum col wise-->"<<endl;
for(int col=0; col<3; col++){
int sum=0;
for(int row=0; row<3; row++){
sum += arr[row][col];
}
cout<<sum<<" ";
}
cout<<endl;
}
int main(){
int arr[3][3];
cout<<"Enter the element of array:- "<<endl;
//taking input
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
cin>>arr[i][j];
}
}
//printing
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
cout<<arr[i][j]<<" ";
}
cout<<endl;
}
printRowSum(arr,3,3);
printColSum(arr,3,3);
return 0;
}