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
- Add two header file for math and pattern.
- Declare a double variable for input.
- Take input from user.
- Use sin, cos , tan in cout for output.
- In last, display output on the screen in a pattern.
- Return 0 to the main function.
0 Comments