text cover

Data Abstraction and Problem Solving with C++

Walls and Mirrors

by Frank M. Carrano

Addison Wesley Logo

c01p032.cpp File Reference


Detailed Description

Verification: Examples of loop invariants.

The for loop on j computes $n!$ for an integer $n \geq 0$

Confirm that the following invariant holds on the for loop:

Invariant:
$f == (j-1)!$
The while loop computes an approximation to $e^{x}$ for a real $x$

Confirm that the following invariant holds on the while loop:

Invariant:

\[t == \frac{x^{(k-1)}}{(k-1)!}\]

and

\[s == 1 + x + \frac{x^{2}}{2!} + \dots + \frac{x^{(k-1)}}{(k-1)!}\]

Date:
29 May 2006
Chapter:
Chapter 1
Page:
Page 32
Version:
5.0

Definition in file c01p032.cpp.

Go to the source code of this file.


Generated on Sat Aug 26 19:58:10 2006 for AWLogo by  doxygen 1.4.6