Hey everyone. I need a little exponent help.

This is the problem that I am currently working on:

***Note: Since I don't know if I can use {sup}{/sup} and html on here, I will simply type my exponents in graphing calculator format.. like 5 ^ 3 = (5*5*5)=125 ***

"Write an interactive C++ program to calculate the following summation using an iteration,

Sum = 1 + 1/2 + 1/4 + ... + 1/2n (note: the n is an exponent for the denomenator, as 1/(2^n) )

Your program should prompt for the value of n. Please show your results for n = 10.

The series above has a closed form analytical solution, namely,

Sum(n) = 2 - 1/2n = 1 + 1/2 + 1/4 + ... + 1/2n (note: the n is an exponent for the denomenator, as 1/(2^n) )

In the output for your C++ program, compare the iterative solution to the analytical solution. "

I'm not exactly sure what to do...While poking around google, I found solutions to base/exponent problems. If I follow these, I think I may need <math.h> or <cmath> in order to do exponents with the "pow" command. Upon reviewing my problem, however, I began to wonder if maybe I need a loop or something. My teacher was explaining this problem on the board, and told us that the ... in "1 + 1/2 + 1/4 + ... + 1/2n " meant something like 1/(2^0) + 1/(2^1) + 1/(2^2) + ... + 1/(2^n) . Have any thoughts/tips/suggestions?

As always, any help would be greatly appreaciated.