Skip to content
Programmingoneonone
Programmingoneonone

Learn everything about programming

  • Home
  • CS Subjects
    • Internet of Things (IoT)
    • Digital Communication
    • Human Values
    • Cybersecurity
  • 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
Programmingoneonone
Programmingoneonone

Learn everything about programming

HackerRank A Very Big Sum problem solution

YASH PAL, 31 July 202430 November 2025

Hackerrank A very big sum problem solution – Today we are going to solve Hackerrank a very big sum problem in python, java, c++, c and javascript programming . so 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()

A very big sum 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);
    }
}

 

A very big sum solution in C++.

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

 

A very big sum solution in C.

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

 

A very big sum solution in JavaScript.

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

Leave a Reply

Your email address will not be published. Required fields are marked *

Are you a student and stuck with your career or worried about real-time things, and don't know how to manage your learning phase? Which profession to choose? and how to learn new things according to your goal, and land a dream job. Then this might help to you.

Hi My name is YASH PAL, founder of this Blog and a Senior Software engineer with 5+ years of Industry experience. I personally helped 40+ students to make a clear goal in their professional lives. Just book a one-on-one personal call with me for 30 minutes for 300 Rupees. Ask all your doubts and questions related to your career to set a clear roadmap for your professional life.

Book session - https://wa.me/qr/JQ2LAS7AASE2M1

Pages

  • About US
  • Contact US
  • Privacy Policy

Follow US

  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2026 Programmingoneonone | WordPress Theme by SuperbThemes