This C++ program computes inverse of a trigonometric ratio. The program enters a choice as to inverse of which trigonometric ratio the user wants to compute the value. The user enters the trigonometric ratio of the chosen type and the inverse of trigonometric ratio is computed and printed.
Here is the source code of the C++ program computes inverse of a trigonometric ratio. The C++ program is successfully compiled and run on a Linux system. The program output is also shown below.
/*
* C++ Program to Obtain Inverse of a Trigonometric Ratio
*/
#include <iostream>
#include <cmath>
#include <iomanip>
int main()
{
double value, result;
int choice;
std::cout << "Enter a choice " << std::endl;
std::cout << "1. Inverse Sine" << std::endl;
std::cout << "2. Inverse Cosine" << std::endl;
std::cout << "3. Inverse Tangent" << std::endl;
std::cin >> choice;
switch (choice) {
case 1:
std::cout << "Enter a value ";
std::cin >> value;
std::cout << "asin(val) = " << std::setprecision(3)
<< asin(value) << std::endl;
break;
case 2:
std::cout << "Enter a value ";
std::cin >> value;
std::cout << "acos(val) = " << std::setprecision(3)
<< acos(value) << std::endl;
break;
case 3:
std::cout << "Enter a value ";
std::cin >> value;
std::cout << "atan(val) = " << std::setprecision(3)
<< atan(value) << std::endl;
break;
}
return 0;
}
$ a.out Enter a choice 1. Inverse Sine 2. Inverse Cosine 3. Inverse Tangent 1 Enter a value 1 asin(val) = 1.57
Sanfoundry Global Education & Learning Series – 1000 C++ Programs.
advertisement
advertisement
If you wish to look at all C++ Programming examples, go to C++ Programs.
Related Posts:
- Practice Computer Science MCQs
- Apply for Information Technology Internship
- Check Programming Books
- Check C++ Books
- Apply for C++ Internship