Skip to main content

Section 9.6 Arrays-WE2-P3

Subsection 9.6.1 Subgoals for Evaluating Arrays

  1. Set up array from 0 to size-1

  2. Evaluate data type of statements against array

  3. Trace statements, updating slots as you go

    1. Remember assignment subgoals

Subsection 9.6.2 Arrays-WE2-P3

Assume the following given declarations:

int [] gamma;

Give the contents of alpha after the execution of these statements.

gamma = new int[6];
gamma[0] = 50;
for (int i = 1; i < 6; i++)
    gamma[i] = gamma[i-1] - 5;

Exercises Exercises

1.

Q20: The value of gamma[0] is |blank|.

2.

Q21: The value of gamma[1] is |blank|.

3.

Q22: The value of gamma[2] is |blank|.

4.

Q23: The value of gamma[3] is |blank|.

5.

Q24: The value of gamma[4] is |blank|.

6.

Q25: The value of gamma[5] is |blank|.

You have attempted of activities on this page.