Sunday, October 26, 2014

Java program to print the sum of array of elements



class SingleArray
{
    public static void main (String args[])
    {
  
        int number_array [] = {10,30,50,70,90,110};
        int result = 0;
        for (int ctr = 0; ctr < 6; ctr++)
               result = result + number_array [ctr];
System.out.println ("Sum of the array elements is : " +result);
}
}

No comments:

Post a Comment