Menu
Question Index
...

Write a program to get the sum of all elements in array.

Input (Integer Array) Output (Integer)
{2, 3, 4, 7, 6, 1} 2 + 3 + 4 + 7 + 6 + 1 = 23
{3, 9, 1, 5, 16, 10} 3 + 9 + 1 + 5 + 16 + 10 = 44
{21, 22, 23, 80, 443, 1521, 8000, 8080} 21 + 22 + 23 + 80 + 443 + 1521 + 8000 + 8090 = 18190



class SumOfNumbersInArray
{
    public static void main(String s[])
    {
        int sum = getSumOfArrayElements(new int[]{2, 3, 4, 5, 8});
        System.out.println("Sum of elements in array is " + sum);

    }


    public static int getSumOfArrayElements(int[] array)
    {
        int result = 0;
    
        return result;
    }

}

Doubts

Problems

Topic: Learn Arrays And Loops

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App