C++ Program to Find the Inverse of a Trigonometric Ratio

«
»
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.

  1. /*
  2.  * C++ Program to Obtain Inverse of a Trigonometric Ratio
  3.  */
  4. #include <iostream>
  5. #include <cmath>
  6. #include <iomanip>
  7.  
  8. int main()
  9. {
  10.     double value, result;
  11.     int choice;
  12.  
  13.     std::cout << "Enter a choice " << std::endl;
  14.     std::cout << "1. Inverse Sine" << std::endl;
  15.     std::cout << "2. Inverse Cosine" << std::endl;
  16.     std::cout << "3. Inverse Tangent" << std::endl;
  17.     std::cin  >> choice;
  18.     switch (choice) {
  19.         case 1:
  20.             std::cout << "Enter a value ";
  21.             std::cin  >> value;
  22.             std::cout << "asin(val) = " << std::setprecision(3)
  23.                       << asin(value) << std::endl;
  24.             break;
  25.         case 2:
  26.             std::cout << "Enter a value ";
  27.             std::cin  >> value;
  28.             std::cout << "acos(val) = " << std::setprecision(3)
  29.                       << acos(value) << std::endl;
  30.             break;
  31.         case 3:
  32.             std::cout << "Enter a value ";
  33.             std::cin  >> value;
  34.             std::cout << "atan(val) = " << std::setprecision(3)
  35.                       << atan(value)  << std::endl;
  36.             break;
  37.     }
  38.     return 0;
  39. }

$ 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.

Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!
advertisement
advertisement
If you wish to look at all C++ Programming examples, go to C++ Programs.

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & technical discussions at Telegram SanfoundryClasses.