-
floating point values
i am trying to do the following:
program that reads two floating-point values representing angles and displays a message stating which angle has the greater tangent value. Note that the trigonometric functions in the math library expect angles in radians, not degrees. 360 degrees = 2 x pi radians, so 45 degrees would be about 0.785 radians.
I have come up with code that takes in 2 numbers and displays the highest values. What I am stuck on is the calculations part. I am searching online and reading the books. Any help in this area will be great. Here is the code I have so far:
Code:
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
int main()
{
float x,y;
cout<< "Enter the first angle: ";
cin>> x;
cout<< "Enter the second angle: ";
cin>> y;
if ( x > y )
cout << " The highest angle is "<< x <<endl;
else
cout<< "The highest angle is "<< y <<endl;
}
-
Code:
(acos(-1) * user_input) /180;
Converts it to radians.
acos(-1) = arccos(-1) = Pi
Though, in your code you use no trig functions so why does it matter.
Also though, just because a number is negative does not mean it is a smaller angle, but the < > will take negative numbers as smaller.