#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int main(){

  cout.setf(ios::fixed);
  cout.setf(ios::showpoint);
  cout.precision(3);
  
  int i, terms;

  cout << "Enter the number of terms to approximate (or zero to quit):\n";
  cin >> terms;
  
    while(1){
      
        if (terms == 0){
          return 0;
        }
        
            if (terms > 0){
            
            double partial = 0;
            
            for (i = 0; i < terms; i++)
                if (i % 2 == 0)
                    partial -= (pow(-1,terms))/((2.0 * i) + 1);
                else
                    partial += (pow(-1,terms))/((2.0 * i) + 1);
                    
            double newPi = 4 * partial;
            
            cout << "The approximation is " << newPi << " using " << terms << " terms.\n";
            
          }
        
        cout << "Enter the number of terms to approximate (or zero to quit):\n";
        cin >> terms;
        
    }
  
  return 0;
}