Need help with Arithmetic

hello, i am new to c++ and need help with an arithmetic problem. i have have tried many ways of rearranging it but still come up with the wrong answer.can someone please help me.the answer i am getting is -11.3 and the answer i was expecting is 23.09 using the values of s = 30, d = 35, e = 20.

Thanks

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
int main()
{
  double s, d, e, VX;

  cout << "Enter initial ball speed: ";
  cin >> s;
  cout << "Enter initial ball direction angle (degrees): ";
  cin >> d;
  cout << "Enter initial ball elevation angle (degrees): ";
  cin >> e;
  VX = s*cos(e)*cos(d);
  cout << VX;

return 0;
}
The std::cos() function expects radians, not angles.
http://www.cplusplus.com/reference/cmath/cos/

So convert the angles to radians by using the formula:
angle * PI / 180.0

where const double PI = 3.14159265;
Thx for the advice i will have a go at it now.

thanks again
Topic archived. No new replies allowed.