Skip to content
Programming101
Programmingoneonone

Learn everything about programming

  • Home
  • CS Subjects
    • IoT – Internet of Things
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
  • HackerRank Solutions
    • HackerRank Algorithms Solutions
    • HackerRank C problems solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
Programming101
Programmingoneonone

Learn everything about programming

HackerRank A Very Big Sum problem solution

YASH PAL, 31 July 20243 May 2025

In this HackerRank A Very Big Sum problem solution In this challenge, you are required to calculate and print the sum of the elements in an array, keeping in mind that some of those integers may be quite large.

Function Description

Complete the aVeryBigSum function in the editor below. It must return the sum of all array elements.

aVeryBigSum has the following parameter(s):

  • int ar[n]: an array of integers.

Return

  • long: the sum of all array elements

Input Format

The first line of the input consists of an integer n.

The next line contains n space-separated integers contained in the array.

Output Format

Return the integer sum of the elements in the array.

HackerRank a very big sum solution
A very big sum problem solution

HackerRank A very big sum problem solution in Python.

#!/bin/python3

import math
import os
import random
import re
import sys

# Complete the aVeryBigSum function below.
def aVeryBigSum(ar):
    x=0
    for i in range(0,len(ar)):
        x= x + ar[i]
    return x


if __name__ == '__main__':
    fptr = open(os.environ['OUTPUT_PATH'], 'w')

    ar_count = int(input())

    ar = list(map(int, input().rstrip().split()))

    result = aVeryBigSum(ar)

    fptr.write(str(result) + 'n')

    fptr.close()

Problem solution in Java Programming.

import java.util.Scanner;

public class BigSum {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        long sum = 0;
        while (N-- > 0 ) {
            sum += scanner.nextInt();
        }
        System.out.println(sum);
    }
}

 

Problem solution in C++ programming.

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


int main() {
    int t;
    double res=0;
    cin>>t;
    int table[5];
    for(int i=0;i<t;i++){
        cin>>table[i];
        res+=table[i];
    }
    cout<<fixed<<std::setprecision(0)<<res;
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */   
    return 0;
}

 

Problem solution in C programming.

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int main() {

   long long int arr[10];
    int n,i;
    scanf("%d",&n);
        long long int sum;
    sum=0;
    for(i=0;i<n;i++)
        scanf("%lli",&arr[i]);
     for(i=0;i<n;i++)
         {
         sum=sum+arr[i];
     }
    printf("%lli",sum);
    return 0;
}

 

Problem solution in JavaScript programming.

process.stdin.resume();
process.stdin.setEncoding('ascii');

var bob = "";
var joe = "";
var tom = 0;

process.stdin.on('data', function (data) {
    bob += data;
});

process.stdin.on('end', function () {
    joe = bob.split("n");
    var res=0;
    var n = parseInt(joe[tom].trim(), 10);
    tom += 1;
    var _line = joe[tom].trim();
    var line = _line.split(" ");
    for (var i = 0; i<n;i++) {
        res+=parseInt(line[i],10);
    }
    process.stdout.write(res);
});

Other problems solutions

  • HackerRank Diagonal difference problem solution
  • HackerRank Plus minus problem solution
  • HackerRank Mini-Max sum problem solution
  • HackerRank Birthday cake candles problem solution
  • HackerRank Time conversion problem solution
Algorithms coding problems solutions AlgorithmsHackerRank

Post navigation

Previous post
Next post
  • Automating Image Format Conversion with Python: A Complete Guide
  • HackerRank Separate the Numbers solution
  • How AI Is Revolutionizing Personalized Learning in Schools
  • GTA 5 is the Game of the Year for 2024 and 2025
  • Hackerrank Day 5 loops 30 days of code solution
How to download udemy paid courses for free

Pages

  • About US
  • Contact US
  • Privacy Policy

Programing Practice

  • C Programs
  • java Programs

HackerRank Solutions

  • C
  • C++
  • Java
  • Python
  • Algorithm

Other

  • Leetcode Solutions
  • Interview Preparation

Programming Tutorials

  • DSA
  • C

CS Subjects

  • Digital Communication
  • Human Values
  • Internet Of Things
  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2025 Programmingoneonone | WordPress Theme by SuperbThemes