*sin(x)=x-x^3/3!+x^5/5!-x^7/7!.....

 float hehe(float x)

{

    int i, j, l;

    float m=1, p=-1, n=1, k=0;

    

        for(i=1;i<=10;i++)

        {

            for(l=1;l<=i;l++)

            p=p*(-1);

            

            for(j=1;j<=2*i-1;j++)

            {

                m=m*x;

                n=n*j;

                

               

                

            } 

            k=k+(p*m)/n;

            printf("%f\n", k);

        }

        

     return k;   

    

}


int main()

{

  

    float y, x;

    printf("Enter the value of x in degrees\n");

    scanf("%f", &x);

    x=x*(3.14/180.0);

    y=hehe(x);

    printf("sin(x)=%f", y);


    return 0;

}


Comments