I'm trying to approximate pi in a C++ program. I'm new to the language, and am not understanding why my pi variable wont change
The code:
double pi = 1;
for (int i = 0; i <+ k; i++){
int denominator = (i * 2) + 3;
if (i % 2 == 0){pi -= (1 / denominator);}
else{pi += (1 / denominator);}
}
pi *= 4;
cout << "Approximation of pi is " << pi << endl;