#include "header.h" int main (void) { float x; int i,n; time_t t1,t0; FILE *fIn; fIn=fopen("test","r"); // open the test file time(&t0); // initial timing fscanf (fIn,"%d", &n); // read the file and assign a number to n, which is the number of x-values printf (" #x\t Cordic(x) MySine(x) sin(x)\n"); // set up the first line for the table for ( i=1; i<=n; i++) // There are n loops { fscanf (fIn,"%f", &x); // read the file "test" and assign a number to x between 0 and 1 printf ("%.6lf ",x); // print the x-value printf ("%.6lf ", Cordic(x)); // calculate sin(x) using the Cordic algorithm printf ("%.6lf ", MySine(x)); // calculate sin(x) using the Maclaurin polynomial printf ("%.6lf\n",sin(x)); // calculate sin(x) using the library sine function } time(&t1); // ending timing printf ("\nThe running time is %.6lf seconds.\n", (float) t1-t0); fclose(fIn); // close the test file return 0; }