PROGRAM:
#include<stdio.h>
#include<math.h>
int factorial(int n)
{
int
i,sum=1; for(i=1;i<=n;i++)
sum=sum*i; return sum;
}
main()
{
int i,n,j,dr;
float res=0.0,x,nr;
printf("\nEnter
the Value of x\n"); scanf("%f",&x);
printf("\nEnter
the total no of terms\n"); scanf("%d",&n);
j=1;
for(i=1;i<n*2;i+=2)
{
nr=pow(x,i)*j;
dr=factorial(i);
res+=(nr/dr);
j=-j;
}
printf("The Result
of sine series is : %f\n",res);
}
OUTPUT:
Enter
the Value of x 0.21
Enter
the total no of terms 5
The Result of sine series is : 0.208460
No comments:
Post a Comment