Programming Challenge Chapter 3 – Q #20 Angle Calculator – Tony Gaddis – Starting Out With C++

Programming Challenge Chapter 3 – Q #20 Angle Calculator – Tony Gaddis – Starting Out With C++



Problem: -

Write a program that asks the user for an angle, entered in radians. The program should then display the sine, cosine, and tangent of the angle. (Use the sin, cos, and tan library functions to determine these values.) The output should be displayed in fixed-point notation, rounded to four decimal places of precision.

Solution: -

#include <iostream>

#include <iomanip>

#include <cmath>

using namespace std;

int main()

{

      double angle;

      cout << "Enter Angle In Radiun: ";

      cin >> angle;

      cout << setprecision(4) << showpoint << fixed;

      cout << "\nAngle into Sine    =  " << sin(angle) << endl;

      cout << "Angle into Cos     =    " << cos(angle) << endl;

      cout << "Angle into Tangent =    " << tan(angle) << endl;

      return 0;

}


This is the solution of this question




OUTPUT OF THIS QUESTION 

Input is highlighted with yellow color.


Explanation of this Solution

  1. Add two header file for math and pattern.
  2. Declare a double variable for input.
  3. Take input from user.
  4. Use sin, cos , tan in cout for output.
  5.  In last, display output on the screen in a pattern.
  6. Return 0 to the main function.

Also, I attach CPP file of this problem. You can download this file

Click Here to Download This File





Post a Comment

0 Comments