The Sin of X can be calculated approximately by using the first n terms of the infinite series
The Sin of X can be calculated approximately by using the first n terms of the infinite series( X is expressed in radians,
/*program to find sine of x can be calculated approximately by using the firstn terms of the infinite series.
Programmed by : kiran shrestha
roll no. : 10121
Programmed on : 6th feb,2011*/
#include <stdio.h>
#include <conio.h>
#include <math.h>
void main ()
{
int i,j,n;
float sum=0,fact=1,x;
printf (“enter terms = “);
scanf (“%d”,&n);
printf (“enter the angle of x = “);
scanf (“%f”,&x);
x =(x*22)/(7*180);
for (i=1;i<=n;i++)
{
for (j=1;j<=2*i-1;j++)
{
fact *=i;
sum += pow(x,(2*i-1))*pow(-1,(i+1))/fact;
}
}
printf (“sum =%f”,sum);
getch ();
}
Comments (1)