Java Program to find Sum the elements of an Array

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


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


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

Java Code:


Sum of all array elements: 240

Top Companies Interview Questions..-


If you find anything incorrect or you feel that there is any better approach to solve the above problem, please write comment.

You may also like...

Leave a Reply

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

%d bloggers like this: