fork download
  1. //Eesha Tangirala #CS1A Chapter 3, pg. 147, #20
  2.  
  3. //************************************************************************************
  4.  
  5. //Calculate Angle Conversion
  6.  
  7. //___________________________________________________________________________________
  8. //This program computes the sin, cos, & tangent of an angle using an
  9. //angle entered in radians.
  10. //___________________________________________________________________________________
  11.  
  12. //INPUT
  13. //Angle (in radians)
  14.  
  15. //Output
  16. //Sin Angle
  17. //Cos Angle
  18. //Tan Angle
  19.  
  20. //***********************************************************************************
  21.  
  22. #include <iostream>
  23. #include <iomanip>
  24. #include <cmath>
  25. using namespace std;
  26.  
  27. int main() {
  28. //Data Dictionary
  29. float angle;
  30.  
  31. //INPUT
  32. cout << "Enter an angle in radians." << endl;
  33. cin >> angle;
  34.  
  35. //Calculate Trig Conversion
  36. float angleRad = angle * (180/M_PI);
  37.  
  38. //Display Data
  39. cout << "The sine of the angle is " << sin(angleRad) << setprecision(4) << endl;
  40. cout << "The cosine of the angle is " << cos(angleRad) << setprecision(4) << endl;
  41. cout << "The tan of the angle " << tan(angleRad) << setprecision(4) << endl;
  42.  
  43. return 0;
  44. }
Success #stdin #stdout 0.01s 5288KB
stdin
50
stdout
Enter an angle in radians.
The sine of the angle is -0.336726
The cosine of the angle is 0.9416
The tan of the angle -0.3576