Hello, I have a program that I am trying to write. I want it to ask the user for an angle in radians, then the desired accuracy the user wants to use, and then the answer. The angle should appear as the x in the answer sin(x) = # (Demonstrated below and a I especially need help with this part).
The program uses the Taylor series for sinx (x - x^3/3! + x^5/5! - x^7/7! + ...) to solve. The end product should look like this:
Enter angle in radians
Enter the desired accuracy
sin(1.57) = 1
Here is what I have so far:
using namespace std;
float sinx, x, acc, term;
int n = 1;
cout << "Enter angle in radians " << endl;
cin >> x;
cout << "Enter the desired accuracy " << endl;
cin >> acc
sinx = 0;
term = x;
while (abs(term) >= acc)
sinx = sinx + term;
term = -term*x*x/((2*n-2)*(2*n-1));
cout << "sin(x) = " << sinx << endl;
I keep getting errors and am still new to C++ so I'm not sure what the mean:
sinx.cpp: In function 'int main()':
sinx.cpp:15: error: expected ';' before 'sinx'
Thanks for any advice!!