Sunday, 2 April 2017

Hacker Rank Solution For " Simple Array Sum " in C++

Problem :- Simple Array Sum

Submit Your Solution Here :- Click Here

Copy The Color Code and paste it into hackerrank Editor .

Solution :-

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

int main(){
    int n,sum=0;
    cin >> n;
    vector<int> arr(n);
    for(int arr_i = 0;arr_i < n;arr_i++){
       cin >> arr[arr_i];
        sum+=arr[arr_i];
    }
    cout<<sum;
    return 0;
}



Output :-

Hacker Rank Solution For " Simple Array Sum " in C++

No comments:
Write comments

Recommended Posts × +