Ask Question
1 January, 15:04

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.

+1
Answers (2)
  1. 1 January, 16:34
    0
    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.
  2. 1 January, 17:10
    0
    2. Tests if the elements in the array are even or odd.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “What does the following algorithm do? public static void mystery (int nums[]) { for (int i = 0; i < nums. length; i++) { if (nums[i] % 2! = ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers