Ask 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 - 1] + 3;

}

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

a.

10

c.

15

b.

13

d.

17

+1
Answers (1)
  1. 21 January, 11:37
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers