Hello, the code below is an extract from a small program which lets the user choose the number of iterations (for an approximation of PI/4). The program works, however i do not understand how it is working. Please help me understand the following lines...
for (int i=0; i<iteration; i++) { //i understand this double sum = 1.0/(2.0*(i) + 1.0); //just the formula if (positive) //do not understand this!! output += sum; //same as output = output + sum else output -= sum; // same as output = output - sum positive = !positive; // not sure how this is helping with the program!
Thanks!