9.3.1. Arrays-WE3-P1ΒΆ
Subgoals for Evaluating Arrays
Set up array from 0 to size-1
Evaluate data type of statements against array
Trace statements, updating slots as you go
Remember assignment subgoals
Arrays-WE3-P1
Q31: Assume the following given declarations:
int [] beta = {12, 24, 36, 48, 60};
Evaluate these statements:
beta[1] = beta[3] - beta[1] + 6;
beta[3] = beta[beta[4] % beta[0]];
beta[2] = beta[beta[4]/beta[0]-1];
Give the contents of array beta
after the execution of the above statements:
beta[0] =
beta[1] =
beta[2] =
beta[3] =
beta[4] =
For questions 32-36, give the contents of alpha after the execution of these statements.
int alpha = {2, 4, 6, 8, 10};
for (int i = 8; i >= 0; i-=2)
alpha[i/2] = i/2 + 1;
Q32: Enter the values of alpha in the blanks.
The value of alpha[0] is |blank|
.
Q33: Enter the values of alpha in the blanks.
The value of alpha[1] is |blank|
.
Q34: Enter the values of alpha in the blanks.
The value of alpha[2] is |blank|
.
Q35: Enter the values of alpha in the blanks.
The value of alpha[3] is |blank|
.
Q36: Enter the values of alpha in the blanks.
The value of alpha[4] is |blank|
.