Skip to content

Instantly share code, notes, and snippets.

@rahuladream
Created November 5, 2017 12:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rahuladream/b0dcb78ecd03332690091867e351b612 to your computer and use it in GitHub Desktop.
Save rahuladream/b0dcb78ecd03332690091867e351b612 to your computer and use it in GitHub Desktop.
Sample Input 6 1 2 3 4 10 11 |||| Sample Output 31
#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