// file: ppp-01.cpp

#include <cstdlib>
#include <iostream>

using namespace std;
// ----------------------------------------------

#include <math.h>
#define pi (4.0*atan(1.0))
// ----------------------------------------------

int main(int argc, char *argv[])
{
   FILE *f1;
   f1= fopen("plot-sin.scr", "wt");
   
   // plot y= sin(), x= 0 to pi step dx
   // dx= (x2 - x1)/no
   int no= 16;
   double x, y, x1, x2, dx;
   
   x1= 0.0;
   x2= pi;
   dx= (x2 - x1)/no;
   
   // for x= x1 to x2 step dx
   fprintf(f1, "spline\n");
   for (x= x1;x <= (x2 + dx/10.0);x+= dx) {
       y= sin(x);
       
       fprintf(f1, "%.6lf,%.6lf\n", x, y);
   }// end for
   fprintf(f1, "\n\n\n");
   fclose(f1);
   
   printf("\n Done! \n");
   system("PAUSE");
   return EXIT_SUCCESS;
}// end main()
