fork download
  1. //Ryan Shahriyarpour CS1A Carl Argila CH3 HW Q:20
  2. //
  3. /*****************************************************************************
  4.  *
  5.  * Angle Calculator Program
  6.  *
  7.  *
  8.  * ***************
  9.  *
  10.  * The goal of the program is to calculate sine, cosine, and tangent of an angle in radians
  11.  *
  12.  *
  13.  * ******************
  14.  *
  15.  *
  16.  * INPUT
  17.  * angle : Angle in radians
  18.  *
  19.  * OUTPUT
  20.  * sine : Sine of the angle
  21.  * cosine : Cosine of the angle
  22.  * tangent : Tangent of the angle
  23.  *
  24.  ****************************************************************************/
  25.  
  26. #include <iostream>
  27. #include <iomanip>
  28. #include <cmath>
  29. using namespace std;
  30.  
  31. int main() {
  32. double angle;
  33. double sine;
  34. double cosine;
  35. double tangent;
  36.  
  37.  
  38. cout << "Enter an angle in radians: ";
  39.  
  40. // Store angle value
  41. cin >> angle;
  42.  
  43. // Calculate sine of angle
  44. sine = sin(angle);
  45.  
  46. // Calculate cosine of angle
  47. cosine = cos(angle);
  48.  
  49. // Calculate tangent of angle
  50. tangent = tan(angle);
  51.  
  52. // Display result to proper decimal
  53. cout << fixed << setprecision(4);
  54. cout << "Sine: " << sine << endl;
  55. cout << "Cosine: " << cosine << endl;
  56. cout << "Tangent: " << tangent << endl;
  57.  
  58. return 0;
  59. }
Success #stdin #stdout 0.01s 5312KB
stdin
Standard input is empty
stdout
Enter an angle in radians: Sine: 0.0000
Cosine: 1.0000
Tangent: 0.0000