Skip to main content

Section 10.6 Arrays-WE2-P3

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 10.6.1

Assume the following given declarations:
int [] gamma;
Give the contents of gamma 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 .
2.
Q21: The value of gamma[1] is .
3.
Q22: The value of gamma[2] is .
4.
Q23: The value of gamma[3] is .
5.
Q24: The value of gamma[4] is .
6.
Q25: The value of gamma[5] is .
You have attempted of activities on this page.