Created
November 5, 2017 12:57
-
-
Save rahuladream/b0dcb78ecd03332690091867e351b612 to your computer and use it in GitHub Desktop.
Sample Input 6 1 2 3 4 10 11 |||| Sample Output 31
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
#include <bits/stdc++.h> | |
using namespace std; | |
int simpleArraySum(int n, vector <int> ar) | |
{ | |
int sum = 0; | |
for(int i = 0; i < n ; i++){ | |
sum += ar[i]; | |
} | |
return(sum); | |
} | |
int main() { | |
int n; | |
cin >> n; | |
vector<int> ar(n); | |
for(int ar_i = 0; ar_i < n; ar_i++){ | |
cin >> ar[ar_i]; | |
} | |
int result = simpleArraySum(n, ar); | |
cout << result << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment