title: C program - taylor series_long formula
body: <p>This formula is from a friend of mine --- and I fixed it up for him. But I can't seem to figure out of how to get the right sine calculations per angle. Can someone please help me in getting the right commands in the sin part?</p>
  
  <p>Code:</p>
  
  <pre><code> #include&lt;stdio.h&gt;
  #define PI 3.141592653589
  #define NUMBER_OF_TERMS 10
  
  
  double factorial(double x)
   {
    double counter, total;
    counter=x;
    total=x;
    while(counter&gt;1)
    {
       counter--;
       total = total * counter;
    }
    return total;
    }
    double power(double x, double y)
    {
    double counter, j;
    counter=0;
    j = x;
    while (counter&lt;(y-1))
    {
          counter++;
          x = x * j;
    }
    return x;
    }
    double cosine_func(double radians)
    {
    int counter, x;
    double cosine;
    x=0;
    counter=0;
    cosine = 0;
    while(counter&lt;NUMBER_OF_TERMS-1)
    {
               counter++;
               x=x+2;
               if(counter%2 == 0)
                {
                    cosine = cosine - (power(radians, x)/factorial(x));
                }
               else if(counter%2 != 0)
               {
                    cosine = cosine + (power(radians, x)/factorial(x));
               }
  
    }
    return cosine;
    }
    double sine_func(double radians)
    {
    int counter, x;
    double sin;
    x=0;
    counter=0;
    sin = 0;
    while(counter&lt;NUMBER_OF_TERMS-2)
    {
               counter++;
               x=x+3;
               if(counter%2 != 0)
                {
                    sin= sin -(power(radians, x)/factorial(x));
                }
               else if(counter%2 != 0)
               {
                  sin= sin + (power(radians, x)/factorial(x));
               }
      }
    return sin;
  
      } 
     main()
   { 
    double counter;       
    double x_angles;         
    double x_radians;  
    double cosine;   
    double sin;      
  
  
    printf("11526769\n\n");
    printf("x(degrees)\t   x(radians)\t\t     cos x\t\t  sin x\t\t");
    counter = 0;
    x_angles = -185;
    while (x_angles&lt;180)
    {
          counter++;
          x_angles+=5;
          x_radians=x_angles*PI/180.0;
          cosine=1-cosine_func(x_radians);
          sin=x_radians-sine_func(x_radians);
          printf("%.2lf\t\t%.12lf\t\t%.12lf\t\t%.12lf\n", x_angles, x_radians, cosine, sin);
    }
    return 0;
    } 
  </code></pre>