What does the following algorithm do?

public static void mystery(int nums[]) {
for (int i = 0; i < nums.length; i++) {
if (nums[i] % 2 != 0)
nums[i]++;
}
}


1. Adds 1 to every value in the array.
2. Tests if the elements in the array are even or odd.
3. Changes all the values in the array to even numbers.
4. Doubles all the values in the array.
5. Doubles every other value in the array.

Respuesta :

2. Tests if the elements in the array are even or odd.
W0lf93
The purpose of the program code is to change each value into an even number. If the number is even already, it does not change the number. If the number is odd, it will add one and change it to an even number.