SUMMATION OF SINE SERIES
#include”stdio.h”
#include “conio.h”
#include
int fact(int);
void main()
{
int i,x;
float sum=0,p,f,x1,n,c=1;
clrscr();
printf("\n Enter the values of x and n : ");
scanf("%d %f",&x,&n);
x1=(x*3.14)/180;
for(i=1;i<=n;i+=2)
{
p=pow(x1,i);
f=fact(i);
c=c*(p/f);
sum=sum+c;
c=c*(-1);
}
printf("\n Summation of Sine series : %f",sum);
printf("\n\n Sin(%d) : %f",x,sin(x1));
getch();
}
int fact(int a)
{
int f=1,i;
for(i=1;i<=a;i++)
f=f*i;
return(f);
}
Output will be
Enter the values of x and n : 56 3
Summation of Sine series : 0.825104
Sin(56) : 0.828760
No comments:
Post a Comment