Skip to content

Commit

Permalink
Merge pull request #25 from areenoverclouds/rowusm
Browse files Browse the repository at this point in the history
Sum of rows of 2D array
  • Loading branch information
unnati914 authored May 25, 2021
2 parents 3320b9f + 343ecaa commit 3a2c6c7
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
27 changes: 27 additions & 0 deletions SumofRows.cpp
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;
}
17 changes: 17 additions & 0 deletions fibonacci.cpp
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;
}

0 comments on commit 3a2c6c7

Please sign in to comment.