I have written a code to calculate this to 100th sentence for pi but it shows "3" this the formula
#include <iostream>
using namespace std;
int main()
{
int n = 1;
double a, P = 0;
for (n; n <= 100; n++) {
a = 4 / (2 * n - 1);
if (n % 2 == 0) {
a = -a;
}
P = P + a;
}
cout << P;
system("pause");
return 0;
}