Thursday, January 27, 2011

Java Program to calculate the sum of array 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);

}
}