[ Write a Program to input 10 numbers into an integer array and display the sum of all number in it.
Program Code :
import java.util.*;
class Sum_of_Array_Element
{
public static void main(String args[])
{
int i,sum=0;
int n[]=new int[10];
Scanner sc=new Scanner(System.in);
//Accepting 10 Array Element
for (i=0;i<10;i++)
{
System.out.print("Enter the Array Element = ");
n[i]=sc.nextInt();
}
//SUM of 10 Array Element
for (i=0;i<10;i++)
{
sum=sum+n[i];
}
System.out.println("Sum of Array Elements = "+sum);
}
}
No comments