LARA

Lecture 05

Continued in Exercise 05

Part 1

Discussion of homeworks 2 and 3.

Part 2 - Programs with arrays

Assume for the following two problems, that run-time exceptions, like for example index out of bounds, do not occur.

Exercise 1

Write down the formula for the following code fragment. Transform the code first into guarded command language and then use the transformations from Lab 04 to get a formula.

i = 0
while(i < n) {
  a[i] = 0;
  i = i + 1;
}