NOTE I need the following to pass in this compiler httpcodec
NOTE: I need the following to pass in this compiler: http://codecheck.it/codecheck/files?repo=bj4cc&problem=ch11/c11_exp_11_102
Please make absolutely sure it passes in that before posting.
~
Complete the method, named sumArray, in the class named ArrayOps.java, so that it sums all the integer values in an array.
The one parameter coming into the method is an array of integers. The integer value returned is the sum of these integers.
Complete the following code:
Solution
public class ArrayOps {
public static void main(String[] args) {
int arr[]={25, 16, 14 };// initialising array
int result=sumArray(arr);// calling sumArray method in main
System.out.println(\"\ sum of the integers in array=\"+result);
}
public static int sumArray(int values[]){// sum array method starts here
int sum=0;
int len=values.length;// finding length
for(int i=0;i<len;i++){// reading array
sum=sum+values[i];// adding array values to sum
}
return sum; // returning sum
}// ends here
}
