Java program to print the sum of all numbers in a given array
Codeaft.java
class Codeaft
{
    public static void main(String args[])
    {
        double sum=0;
        double []a={100,15,15.15,40,45.99};
        for(int i=0;i<a.length;i++)
        {
            sum=sum+a[i];
        }
        System.out.println("The addition of array is = "+sum);
    }
}
Output
codeaft@codeaft:~$ javac Codeaft.java
codeaft@codeaft:~$ java Codeaft The addition of array is = 216.14000000000001 codeaft@codeaft:~$
Comments and Reactions