// Writing trigonometric data to a text file
#include <iostream>
#include <cmath>
#include <iomanip>
#include <fstream>
using namespace std;

int main ()
{
  const float PI=3.1415926;

  string filename = "trigo.data";
  ofstream myFile(filename.c_str());

  if (myFile.is_open())
  {
      cout << "Writing data to the file: " << filename << endl;
      myFile << setprecision(5) << fixed;

      for(int deg=0; deg<=180; deg+=10)
      {
         float x = PI*deg/180.;
         myFile << setw(3)  << deg
                << setw(10) << sin(x)
                << setw(10) << cos(x) << endl;
      }
      myFile.close();
  }
  else
    cout << "Unable to open file " << filename;

  return 0;
}
