Be the first user to complete this post

  • 0
Add to List
Beginner

333. Sum the elements of an Array

Objective: Given an array of integers, write a java program to find the sum of all elements

Example:

Input [] = {20, 30, 40, 10, 5, 2, 60, 73}
Output: 240

Approach:

Do a linear scan and add the elements in the array. See the code, its self explanatory.

Output:

Sum of all array elements: 240