CS 200 - Lab 8

Series sum revisited

In Lab 5 you wrote a program to compute the sum of the first 7 terms of the following series:

1/2 + 1/4 + 1/8 + 1/16 + 1/32 + ...

In this lab, you will write a program to prompt the user for the number of terms to compute.

Example run of the program (user input in bold red):

How many terms? 15
sum is 0.999969

Getting started

If you have a solution open in Visual Studio, close it (File->Close Solution).

Download lab8.zip.  Import it into Visual Studio (File->Import...).

Add your code to the source file called Series.c.


Start by thinking about how, in the body of your loop, you can compute increasing powers of two (2, 4, 8, 16, etc.)