A Very Big Sum
In this post we will be covering A Very Big Sum, in which we have to calculate the total sum of all the elements present in an array, keeping in mind that the value of the element present in the array can be much larger and hence to calculate the sum that can be displayed without an error, The solution is carried out in C++ with the required sets of variables, initializations, looping and output to get.
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.
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.
- long: the sum of all array elements
The first line of the input consists of an integer n.
The next line contains space-separated integers contained in the array.
Return the integer sum of the elements in the array.
Let's write the code for Problem
Sample Test Case Passed Successfully
If you liked this post, then share this with your friends and if anything is confusing or incorrect then let me know in the comment section.
Thanks from my side, this is Mayank, keep learning and exploring !!