Leaderboard
Showing:
C++ Arrays (Sum of array) | Set 1
School Accuracy: 73.31% Submissions: 1255 Points: 0

Given an array of N integers. Your task is to print the sum of all of the integers.
 

Example 1:

Input:
4
1 2 3 4
Output:
10

 

Example 2:

Input:
6
5 8 3 10 22 45
Output:
93

 

Your Task:  
You don't need to read input or print anything. Your task is to complete the function getSum() which takes the array A[] and its size N as inputs and returns the sum of array in a new line.


Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)

 

Constraints:
1 ≤ N ≤ 1000

0 ≤ Arr[i] ≤ 200

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

C++ Arrays (Sum of array) | Set 1

Output Window