java program to find sum array element

java program to take user input

simple java array program

Program:-

import java.util.Scanner;
class group{
public static void main(String arng[]){
int total = 0;
int sum[]=new int[5];
Scanner data = new Scanner(System.in);

System.out.println("Enter 5 element of array");

for(int i=0; i<5;i++)
sum[i] = data.nextInt();
for(int i=0; i<5;i++)
total = total +sum[i];
System.out.println("Sum of array element is:"+total);
}
}

Output:-

Enter 5 elment of array
25
21
23
21
24
Sum of array element is:114

Learn Java:-
Java codes

Java Programs:-
List of Java Programs

Leave reply

Add your comments here

Back to Top