I am trying to make a simple pi calculator in cpp but when I try to run it it only prints out 3. this is my code:
#include <iostream>
using namespace std;
double pi = 0.0;
long unsigned int d = 1;
int main() {
while (true) {
pi += (4/d) - (4/ (d+2));
d += 4;
cout << pi << endl;
}
}
I'm relatively inexperienced with c++ so please help.