9. Consider the following fragment of SPARK Ada code: procedure divide (in x, y: integer; out z:…

 

9.     Consider the following fragment of SPARK Ada code:

procedure divide (in x, y: integer; out z: integer) is

 

begin

z := 0;

while x > y loop x := x – y;

z := z + 1;

end loop; end divide;

(a)       State the pre-condition as SPARK Ada annotation(s).

(b)       State the post-condition as SPARK Ada annotation(s).

(c)       State the loop invariant as SPARK Ada annotation(s).

10.  How would you modify the postcondition from the previous question if the array could have duplicate entries?

11.  Write the Bubble sort program as a procedure in a notation as close to SPARK Ada as you can manage. Include the SPARK annotations that you think should be used.