just a couple of thoughts to start you off...
initialize the number that you're going to be adding to/subtracting from to 0. the start of your equation is pi=4/1+..., so starting it off with zero allows you to do the calculation without the if (termspi == 1) instruction.
use a for loop, not a while loop. the following form will increment 1,3,5,7,9,...:
CODE
long i;
for (i=1; i<(2*termspi-1); i+=2) {
// do calulations here
}
to get the addition/subtraction right, you're probably going to need to use a conditional. you should note that the terms that are added have 1,5,9,... in the denominator, while the terms that are subtracted have 3,7,11,... I'll just put this out there for you to think about: if the term is to be added, the function (denominator-1)%4 is equal to 0; otherwise, it is greater than zero.
please post code in blocks, and you might want to clarify your questions a little more.
hopefully that will give you a starting point for some of this.
-jjh
This post has been edited by jjhaag: 27 Sep, 2007 - 08:27 PM