Ask Question
15 May, 15:55

Int alpha [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;

}

4. What is thevalue of alpha[3] after the code aboveexecutes?

a.

10

c.

15

b.

13

d.

17

+2
Answers (1)
  1. 15 May, 16:07
    0
    Hi.

    The correct answer is b. 13.

    Explanation:

    The values when the iteration was finished is.

    alpha[0] = 5 alpha[1] = 8 alpha[2] = 10 alpha[3] = 13 alpha[4] = 15

    Before iteration alpha[0] = 5.

    First iteration alpha[1] = 5 + 3 = 8.

    Second iteration alpha[2] = 8 + 2 = 10.

    Third iteration alpha[3] = 10 + 3 = 13.

    Last iteration alpha[4] = 13 + 2 = 15.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Int alpha [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 - ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers