-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from areenoverclouds/rowusm
Sum of rows of 2D array
- Loading branch information
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include <iostream> | ||
using namespace std; | ||
|
||
int main() | ||
{ | ||
int i,j, m, n; | ||
cout<<"\nEnter number of rows and coloumns : "; | ||
cin>>m>>n; | ||
int arr[m][n]; | ||
cout<<"\nEnter elements of matrix : \n"; | ||
for (i = 0; i < m; i++) | ||
for (j = 0; j < n; j++) | ||
cin>>arr[i][j]; | ||
|
||
cout << "\nFinding Sum of each row:"; | ||
int sum=0; | ||
|
||
for (i = 0; i < m; ++i) {s | ||
for (j = 0; j < n; ++j) { | ||
sum = sum + arr[i][j]; | ||
} | ||
cout<< "\nSum of the row "<< i << " = " << sum << endl; | ||
sum = 0; | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include <iostream> | ||
using namespace std; | ||
|
||
int main(){ | ||
int num1=0,num2=1,num3,i,n; | ||
cout<<"\nEnter the number of elements of Fibonacci Series : "; | ||
cin>>n; | ||
cout<<num1<<' '<<num2<<' '; //First print 0 and 1 | ||
|
||
for(i=2;i<n;++i){ | ||
num3=num1+num2; | ||
cout<<num3<<' '; | ||
num1=num2; | ||
num2=num3; | ||
} | ||
return 0; | ||
} |