0

I am trying to write a C++ program that will prompt the user to enter an angle value and calculate its sine,cosine and tangent without using c math library.The angle value denoted x,should be in radian,otherwise the program will convert it into radian before it computes its sin,cos and tan.So far i have managed to come up with a code(below) for finding sin of the angle value input but it gives me some errors.I am quite certain that i am on the right track and please help by correcting my incomplete program i posted below because once it is fine i can come up with the code for finding cos and tan

```
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int factorial(int);
int n = 3, i = 1;
double x, x2, b, PI, r;
char choice;
//r = x * (PI / 180)
cout<<"Please enter an angle value => ";
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;
if((choice = 'R')||(choice = 'r'))
do{
i++; n = 3; x2 = 0; b = x2;
{
if(i == 1)
x2 = x - (pow(x,n) /factorial(n));
n = n + 2;
};
else
{
x2 = (x2 + ((pow(x,n)) /(factorial(n))) - (pow(x,n+2)) / (factorial(n+2)));
n = n + 4;
}
}while(abs(b - x2) > 0.000001);
else
//convert it to r
r = x * PI /180;
//cout<<"error occured/n";
cout<<"sin(x) = "<<x2<<endl;
return 0;
}
```

*Edited 3 Years Ago by happygeek*: fixed formatting