/* PROOF OF CORRECTNESS: MULT(X,Y): compute X*Y */ #include <stdio.h> int mult(int x, int y) { int i, z; // PRE: x >= 0 and y >= 0 z = 0; // i = 0; // // INVARIANT: while (i < y) { // z = z + x; // i = i + 1; // } // end while // INVARIANT: and EXIT: // // POST: z = x*y return z; } int main() { printf("mult(2,4)=%d\n",mult(2,4)); }