/* PROOF OF CORRECTNESS: EXP(X,Y): compute X^Y */ #include /* Note: this may get a warning because the return does not match a built-in exp function in C. Ignore the warning. */ int exp(int x, int y) { int i, z; // PRE: x > 0 and y > 0 z = x; i = 2; // INVARIANT: while (i <= y) { z = z * x; i = i + 1; } // end while // INVARIANT: and EXIT: // POST: z = x^y return z; } int main() { printf("exp(2,4)=%d\n",exp(2,4)); return 1; }