Write a C program to implement sine series.
#include<stdio.h>
#include<math.h>
main()
{
float x,sum;
int i,n,x1,t;
int fact(int);
printf("\n\n\t\t SUMMATION OF SIN(X)");
printf("\n\t\t *************************\n");
printf("\nINPUT:");
printf("\n*******");
printf("\n Enter the Degree:\n");
scanf("%d",&x1);
printf("\n Enter the Number of Term:\n");
scanf("%d",&n);
x=(x1*3.14)/180;
t=-1;
sum=x;
for(i=3;i<=2*n;i+=2)
{
sum=sum+t*(pow(x,i)/fact(i));
t=t*(-1);
}
printf("\nOUTPUT:");
printf("\n******");
printf("\n Sin(x) value : %f\n",sum);
printf("\n Built in Function for Sin(x) :
%f\n",sin(x));
getch();
}
fact(int n)
{
int i,f=1;
for(i=1;i<=n;i++)
f=f*i;
return(f);
}
0 comments:
Feel free to contact the admin for any suggestions and help.