i have wrote function Sin(), didn'd use math in libary, but when it run the result error, can you help me? fix it thanks very much.
sin(x)=Tn((-1)^k )*(x^2k+1)/(2k+1)!
Code:
#include <iostream>
using namespace std;
double gt(double d){
if(d==1||d==0)return 1;
return d*gt(d-1);
}
//
double power(double a, int b)
{
double c=1;
for (int h=0; h<b; h++) c*=a;
return c;
}
//
double Mysin(int x){
double Sum=0;
for(int i=1;i<=10;i++){
double tmp=gt(2*i+1);
Sum+=(power(-1,i)*(power(x,2*i+1)))/tmp;
}
return Sum;
}
void main(){
//MySin M;
int x;
cin>>x;
cout<<Mysin(x);
}