# Hacker Rank solution for Simple Array Sum in C++

Problem:- Simple Array Sum solution or Simple Array Sum solution in C++ or Simple Array Sum hacker rank solution in Java or Simple Array Sum hacker rank solution c++ or Simple Array Sum hacker rank solution c++ or Simple Array Sum program in c or Simple Array Sum solution in c or Simple Array Sum hacker rank solution in python or Simple Array Sum in java or Simple Array Sum hacker rank solution in c or Hacker Rank Solution For Simple Array Sum in C++ or Simple Array Sum in C++ or Hacker Rank solution for Simple Array Sum in C++.

Check This- Hacker rank Solution for C++ Sub Domain Introduction, Classes, STL, Inheritance.

Explanation:- Take multiple inputs of the same type and store the input in an array after that with the help of the third variable add or the sum of all available and print the sum of an array. Here is a huge collection of the program in C, C++, and Java. If you want to practice more and more program in C language and C++ Click here for C language and for C++ Click here

Also check- Geeksforgeeks solution for School, Basic, Easy, Medium, Hard Domain.

Copy the full solution or colored code and paste into the hacker rank editor and click to Run Code if the code runs successfully then click to Submit Code. Before pasting the code into the editor make sure you have chosen c++ editor in the top right drop down option.

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];
}

for(int arr_i = 0;arr_i < n;arr_i++)
{
sum+=arr[arr_i];
}
cout<<sum;
return 0;
}

Output:-

Previous Post
Next Post

#### post written by: Ghanendra Yadav

Hi, I’m Ghanendra Yadav, SEO Expert, Professional Blogger, Programmer, and UI Developer. Get a Solution of More Than 500+ Programming Problems, and Practice All Programs in C, C++, and Java Languages. Get a Competitive Website Solution also Ie. Hackerrank Solutions and Geeksforgeeks Solutions. If You Are Interested to Learn a C Programming Language and You Don't Have Experience in Any Programming, You Should Start with a C Programming Language, Read: List of Format Specifiers in C.