- Home
- Course Category
- Course Result
- Course Detail
Hot Line: 0124-2383121
Course Introduction
Includes
Certificate & Practice Material
Programs for practice
In the program below, we've introduced beginers to programming in java
Source Code: Program to find sum of elements of an array
# Program to find sum of elements of an array in java import java.util.Scanner; public class ArraySum { public static void main(String[] args) { //Initialize array int [] arr = {10,20,30,45,56}; // use Scanner class to take input from user here int sum = 0; //Loop through the array to calculate sum of elements for (int i = 0; i < arr.length; i++) { sum = sum + arr[i]; } System.out.println("Sum of all the elements of an array: " + sum); } }Output
Run the program to see the OUTPUT