Respuesta :
Answer:
Option 2: 13
Explanation:
Given the code as follows:
- int[] alpha = new int[5];
- int j;
- alpha[0] = 5;
- for (j = 1; j < 5; j++)
- {
- if (j % 2 == 0)
- alpha[j] = alpha[j - 1] + 2;
- else
- alpha[j] = alpha[j - 1] + 3;
- }
The alpha is an array with size of 5.
The first element of the array has been initialized to 5 (Line 3).
Within the for loop (4 - 10), there is if and else statements that check if the current index j (starting from 1 to 4) is an odd or even number.
If j = 1, the else statement (Line 9) will run and set the alpha[1] to alpha[1-1] + 3 = 5 + 3 = 8
If j = 2, the if statement (Line 7) will run and set the alpha[2] to alpha[2-1] + 2 = 8 + 2 = 10
If j = 3, the else statement will run and set the alpha[3] to alpha[3-1] + 3 = 10 + 3 = 13