(I am trying to write a c++ program which computes sine of an angle without using c math library.I came up with a formula for this problem.The formula should use a factorial function in the program.I have a problem in doing this and hence i posted my code here for you to help me. The code is as below.Thank you in advance.)

```
#include<iostream>
#include<cmath>
using namespace std;
double num();
void for_r();
void for_d();
int factorial();
int main()
{
double x2, x;
char choice;
cout<<"Please enter an angle value \n";
cin>>x;
cout<<"Is the angle value in Degree or Radian?"<<endl;
cout<<"Type D if its in degree "<<endl;
cout<<"Type R if its in radian "<<endl;
cin >> choice;
switch(choice)
{
case 'R':
for_r();
break;
case 'r':
for_r();
break;
case 'D':
for_d();
break;
case 'd':
for_d();
break;
default:
cout<<"Wrong input"<<endl;
}
cout<<"sin(x) = "<<num<<endl;
return 0;
}
void for_r(){
int n = 3;
double x2= 0, b, PI,r;
double sum = num();
for(int i = 1;sum > 0.000001; i++){
if(i == 1){
x2 = num() - (pow(num(),n) /factorial() );
n = n + 2;
}
else
{
x2 = (x2 + ((pow(num(),n))/(factorial())) - (pow(num(),n+2) / factorial()+2));
n = n + 4;
}
}
}
void for_d(){
double x2= 0, PI, r;
int n = 3;
r =( num() * (PI /180));
double sum = num();
for(int i = 1;sum > 0.000001; i++){
if(i == 1){
x2 = num() - ((pow(num(),n) /factorial()));
n = n + 2;
}
else
{
x2 = (x2 + ((pow(num(),n))/factorial() ) - (pow(num(),n+2) /(factorial()+2)));
n = n + 4;
}
}
}
double num(){
int n = 3;
double x2, x;
x2 =(x2 + ((pow(num(),n))/factorial())-(pow(num(),n+2)/(factorial()+2)));
n = n + 4;
return (x2);
}
int factorial(){
int n = 3;
return (n * factorial ()-1);
}
```