C++ asin()

C++ asin() returns inverse sine a number in radians.

Syntax

The syntax of C++ asin() is

asin(x)

where

ParameterDescription
xA double, float, or long double number. The allowed range of x is [-1, 1]

Returns

The return value depends on the type of value passed for parameter x. The return value of asin(x) is

  • double if x is double.
  • float if x is float.
  • long double if x is long double.

The synopsis of asin() function is

double asin(double x);
float asin(float x);
long double asin(long double x);
double asin(T x); // for integral type argument values

asin() is a function of cmath library. Include cmath library in the program, if using asin().

Example

In this example, we read x value from the user and find the inverse sine of this value using asin() function.

C++ Program

#include <iostream>
#include<cmath>
using namespace std;

int main() {
    double x;
    cout << "Enter a value : ";
    cin >> x;
    
    double result = asin(x);
    cout << "asin(" << x << ") : " << result << " radians" << endl;
}

Output

Enter a value : 1
asin(1) : 1.5708 radians
Program ended with exit code: 0
Enter a value : 0.5
asin(0.5) : 0.523599 radians
Program ended with exit code: 0

Conclusion

In this C++ Tutorial, we learned the syntax of C++ asin(), and how to use this function to find the inverse sine of a given value, with the help of examples.