Output:
Click Here For Java Online Compiler
Solution:
Average Of Elements Of An Array *** Array Elements Are: [5, 3, 4, -4, -2, 4] Average value of the array elements is : 1.6666666666666667
Click Here For Java Online Compiler
Solution:
import java.util.Arrays; public class ArrayAverage { public static void main(String[] args) { int[] array = {5, 3, 4, -4, -2, 4}; double sum = 0; for (int i = 0; i < array.length; i++) { sum = sum + array[i]; } double average = sum / array.length; System.out.println("Average Of Elements Of An Array ***" + "\n"); System.out.println("Array Elements Are: " + Arrays.toString(array)); System.out.println("Average value of the array elements is : " + average); } }
comment 0 comments:
more_vertsentiment_satisfied Emoticon