C asin Function

The C asin Function is a Math Library Function useful to calculate the Trigonometry Arc Sine value for the specified expression or value. The syntax of the asin is as shown below.

double asin(double number);

The asin() function accepts a double value between -1 and 1 and returns the arc sine value. When we pass other data types, we must explicitly convert them to a double type.

C asin Function Example

The asin Math Function helps you to find the trigonometry Arc Sine for the user-specified values.

This asin program asks the user to enter their own value. Then it will find the arcsine value of the user entered one. Please refer to the SIN Function and math articles to calculate the Sine value of a specified expression.

#include <stdio.h>
#include <math.h>

int main()
{
  double asinValue, number;
  printf("\n Please Enter the Values between -1 and 1 to calculate Arc Sine Value :  ");
  scanf("%lf", &number);
  
  asinValue = asin(number);
  
  printf("\n The Arc Sine value of %lf = %f ", number, asinValue);
  
  return 0;
}
C asin Function Example

Example 2: When we use the asin() function with the parameter value above +1 or below -1, it returns NaN (Not a Number) as the output. Please refer to the acos() and atan() functions to find the arc cosine and arc tangent values.

#include <stdio.h>
#include <math.h>
int main()
{
double a, b;
a = 5.9;
b = -1.25;
printf("%f\n", asin(a));
printf("%f", asin(b));
}
-nan(ind)
-nan(ind)

How to convert asin result to degrees in C?

By default, the math library’s asin function returns the arc sine value in radians. To convert it to degrees, we must multiply the asin() result by 180/π.

#include <stdio.h>
#include <math.h>
#define PI 3.14159265358979323846

int main()
{
double a, b, c;
a = 0.9;
b = asin(a);
c = asin(a) * 180.0 / PI;
printf("Radians = %f\n", b);
printf("Degrees = %.2f", c);
}
Radians = 1.119770
Degrees = 64.16

Using C asinf() and asinl() functions

If we want to find the arc sine value of a floating-point number or the long double data type, we can use the asinf() and asinl() functions. Rather than converting them to a double data type, we can use these functions directly on the values.

#include <stdio.h>
#include <math.h>

int main()
{
float a = 0.4f;
printf("%f\n", asinf(a));

long double x = 0.9L;
printf("%Lf", asinl(x));
}
0.411517
1.1197695149