# 9.5.1. Arrays-WE4-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-WE4-P1

Q37: Given the following code, what is the value in sum after execution?

```
int [] alpha = {2, 4, 6, 8, 10, 12, 14};
int sum = 0;
for (int k = 0; k < alpha.length; k+=2)
sum = sum + alpha[k];
```

Q38: Given the following code, what is the value in sum after execution?

```
int [] beta = new int [5];
int sum = 0;
for (int k = 0; k < beta.length; k++)
beta[k] = 2 * k + 1;
int x = 3;
for (int k = 1; k < beta.length; k++) {
sum += beta[k];
```

You have attempted of activities on this page