#include <iostream>
using namespace std;

int main() {
	
	double pi = 0.0;
	long i;
	int n;
	
	cout << "Enter the value of n: ";   //prompt for input
	cin >> n;                           //store input in "n"
	cout << endl;                       //end line
	
	for (i = 0; i < n; i++)
	{
	    if (i % 2 == 0)                     //if even
	        pi = pi + (1.0 / (2.0 * i + 1.0));
	    else                                //if odd
	        pi = pi - (1.0 / (2.0 * i + 1.0));
	}
	
	pi = 4.0 * pi;                            //multiply by 4
	
	cout << endl << "pi = " << pi << endl;  //display result
	
	return 0;
}