So for a C++ project at college, we need to make a program where you input the lengths of 2 sides of a right angle triangle, and then the program calculates the hypotenuse, and the two angles. So i got the hypotenuse calculated easily but im having trouble with the angles.
Here is the code for calculating one of the angles:
the second line is my attempt to convert radians to degrees but im having trouble with it. i searched all over Google for formulas for converting radians to degrees and the only one i could find was: Angle*(180/pi)
also what library do i need to include to use math.pi? i tried iomanip but that didnt work
Anyways could someone please help me get this figured out?
In terms of the formula remember pi radians is 180 degrees therefore pi/2 is equal to 90 degrees. From here you can work out what 1 degree is in radians and vice versa. As for using pi try doing the following.
#define PI 3.14159265358 //Go as long as you want, the longer the more accurate
#define radianstodegrees(R)((180.0 * R) / PI)//Converts Radians to Degrees
//Implement it
double answer;
double radians; //the angle
answer = radianstodegrees(radians);
There might be a better way to do it though, I have always used this though.
And if you have never used define before you put it below the #include(s)