191k views
1 vote
Int alpha [5];

int j;
alpha [0] = 2
for ( j = 1; j < 5; j++)
alpha [j] = alpha [ j - 1] + 3;
3. What is the value ofalpha[4] after the code aboveexecutes?

a.

5

c.

11

b.

8

d.

14

User Eben Roux
by
5.9k points

1 Answer

2 votes

Answer:

D - 14

Step-by-step explanation:

Each time the program executes an iteration of the for-loop, it works out the current element by adding 3 to the previous element.

alpha[0] = 2

+3

alpha[1] = 5

+3

alpha[2] = 8

+3

alpha[3] = 11

+3

alpha[4] = 14

User Pdinklag
by
5.6k points