/* C PROGRAM FOR SINE SERIES*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
void
main()
{
int n,i,j,k,f;
float x,x1,sum,p;
clrscr();
printf("\n\t SINE SERIES\n");
printf("\n\t~~~~~~~~~~~~~~~");
printf("\n Enter the value of
n:");
scanf("%d",&n);
printf("\n Enter the value of
x:");
scanf("%f",&x);
x1=x*(3.14/180);
sum=x1;
for(i=3;i<=n*2;i+=2)
{
p=pow(x1,i);
f=1;
for(j=1;j<=i;j++)
{
f=f*j;
}
k=-1;
k=k*(-1);
sum=sum+(p/f)*k;
}
printf("\n Sum of the
series:%f",sum);
printf("\n Sine series
value:%f",sin(x1));
getch();
}
OUTPUT:
SINE SERIES
~~~~~~~~~~~
Enter the value of n:2
Enter the value of x:3
Sum of the series:0.052357
Sine series value:0.052309
0 comments:
Post a Comment