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

3 Comments

  1. This comment has been removed by the author.

    ReplyDelete
  2. I really enjoyed reading the Post. It was very informative and useful.
    Best Software Training institute in bangalore
    Best SAP Training institute In Bangalore.
    <a href="http://www.riainstitute.co.in/Advanced-Excel-Training-in-Bangalore.html>Best Advanced Excel Training Institute In Bangalore. </a>

    ReplyDelete

Add your comments here

Back to Top