sine series (sin(x)=x – x^3/3! +x^5/5!……..)

//c program to find the value of sine series
#include<stdio.h>
#define pi 3.1416
void main()
{
int n,i;
float x, sum=0;
printf(“enter the value of angle in degree\n”);
scanf(“%f”,&x);                                                                    // x in degree
printf(“enter the value of n:”);
scanf(“%d”,&n);
x= pi*x/180;                                                                      // x in radian
float t1=x;
for(i=1;i<=n;i++)
{
sum+=t1;
t1= t1*(-x*x)/((i+1)*(i+2));                             //sin(x)=x – x^3/3! +x^5/5!……..
}
printf(“Sin(x)=%f”,sum);
}

OUTPUT

Greater the value of n Greater will be accuracy in result.

Leave a Reply

Your email address will not be published.