//Calculation of Sum of any numbers
import java.util.Scanner;
public class Sum1
{
public static void main(String args[])
{
int n,sum=0;
Scanner sc=new Scanner(System.in);
System.out.println("How many elements");
n=sc.nextInt();
int a[]=new int[n];
System.out.println("Enter elements");
for(int i=0;i<n;i++)
{
a[i]=sc.nextInt();
sum=sum+a[i];
}
System.out.println("Sum of Array Elements="+sum);
}
}
No comments:
Post a Comment
Note: only a member of this blog may post a comment.