# Homework Help with a Simple Program (I'm new to C++)

This is a discussion on Homework Help with a Simple Program (I'm new to C++) within the C++ Programming forums, part of the General Programming Boards category; Hello, I have a program that I am trying to write. I want it to ask the user for an ...

1. ## Homework Help with a Simple Program (I'm new to C++)

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:

1.57
Enter the desired accuracy
0.0000001
sin(1.57) = 1

Here is what I have so far:
Code:
```#include <iostream>
#include <cmath>
using namespace std;

int main()
{
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;
n++;
term = -term*x*x/((2*n-2)*(2*n-1));
}

cout << "sin(x) = " << sinx << endl;

return 0;
}```

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'

2. Code:
`cin >> acc`
What is missing from the end of the above line?
Hint: Semi-?

Tim S.

3. Originally Posted by stahta01
Code:
`cin >> acc`
What is missing from the end of the above line?
Hint: Semi-?

Tim S.
Thank you! I can't believe I overlooked that.

Now, does anyone know how I would make the final output say the value of the angle that I entered. So it would say sin(1.57) = 1 instead of sin(x) = 1?

4. How about printing the value of x like:
Code:
`cout << "sin(" << x << ") = " << sinx << endl;`
Jim

5. Aha! It worked. Thank you!