Explore what CodeHS has to offer for districts, schools, and teachers.
Click on one of our programs below to get started coding in the sandbox!
View All
What does the following code snippet do?
int[] values = {-5, 102, 34, -78, 42}; int myIndex = 0; for (int i = 1; i < values.length; i++) { if (values[i] > values[myIndex]) { myIndex = i; } } System.out.println(values[myIndex]);
Prints the minimum value of the array.
Prints the average value of the array.
Prints the maximum value of the array.
Prints the median value of the array.
Prints the sum of the values in the array.