float sin(float p);
main()
{
float x;
printf("enter x");
scanf("%f",&x);
printf("sin(%f)=%f",x,sin(x));
}
float sin(float p)
{
float x1,sum=0,term;
int i;
x1=p*3.14159266/180;
term=x1;
for(i=1; i<=20; i++)
{
sum=sum+term;
term=term*(-x1*x1)/(2*i*(2*i+1));
}
return sum;
}
Note: Need to be arranged in compiler after copied
OutPut:
enter x90
sin(90.000000)=1.000000