import java.util.*;
class Sum_Array
{
public static void main(String args[])
{
Scanner in=new Scanner(System.in);
int N,i,sum=0;
System.out.println("Enter the size of the array");
N=in.nextInt();
int arr[]=new int[N];
System.out.println("Enter "+N+" Numbers");
for(i=0;i<N;i++)
{
arr[i]=in.nextInt();
sum=sum+arr[i];
}
System.out.println("The Sum of the elements of the array is: "+sum);
}
}
No comments:
Post a Comment