RECURSIVE SINE SERIES


This program evaluates the sine of an angle in radians with an accuracy upto 'n' terms


#include"stdio.h"
#include"math.h"
double fact(int);
float fun(float,int);
main()
{
int n;
float x,s;
clrscr();
printf("enter x in radians and no of terms:");
scanf("%f %d",&x,&n);
s=fun(x,n);
printf("sin(x)=%f",s);
getch();
}

float fun(float x,float n)
{
if(n==0)
return 0;
else
return fun(x,n-1)+pow(-1,n+1)*pow(x,2*n-1)/fact(2*n-1);
}

double fact(int n)
{
double a=1;
while(n>1)
{
a=a*n;
n--;
}
return a;
}


Go to the programs page click here!!

Hosted by www.Geocities.ws

1