PART B: C++ Program with Debian
5) Problem Round-off Errors
For this problem, you can write one program and display the results at the same time.
You must use the Debian version of the UNIX operating system.
As discussed in class, round-off errors can cause problems for some classes of
calculations. This problem will illustrate round-off errors for a problem that involves a
large number of calculations.
a) Write a C++ program to add the number 0.00001 one million times using single-
precision arithmetic. Recall that in C++, floating-point literals are double
precision by default; to declare a single-precision literal you need to add the
suffix "f" or "F".
b) In the same program, repeat (a) using double precision.
c) Can you explain the difference in results between (a) and (b)?
Note: (1) Since this is a looping structure where the number of reps is known, it may be
advisable to use a for-loop with integers for counting.