integer to calculate pi

hey guys, have to design program to prompt for integer that represents the # of terms to use for an approximation of pi. The program I wrote runs, it just runs the loop the amount of times of the integer entered, from 1 to the integer and I only want the one time.. and also need it to only allow the integer to be less than 10,000,000 and wasn't sure how to add that in there, did some research and tried a couple different methods and they didnt seem to work. any help is much appreciated!
Last edited on
Please use code tags. They make reading and commenting easier.
See http://www.cplusplus.com/articles/jEywvCM9/


You do loop num+1 times. Change that, if you want different number of "terms".

If you want to see the values as they are after the loop, then print them after the loop, not in the loop.

Do use integer loop counter, not double. You can static_cast<double>(i) if necessary.


too small || too large
The logical Or || and logical And && allow more complex boolean logic.
Topic archived. No new replies allowed.