Data Structures, Algorithms, & Applications in C++
Chapter 4, Exercise 1
In each iteration of the do-while
loop, the amount added to elapsedTime
may deviate from the actual run time of
doSomething by up to 100 ms (or 100 ticks).
This error is additive over the iterations and so does not
decline as a fraction of total time.
For example, suppose that doSomething
takes almost 100 ms. to execute.
In the worst case, the clock reading will change just before each
execution of the assignment startTime = clock() and the amount added to
elapsedTime is zero on each iteration of the
do-while loop; the do-while
loop does not terminate.