Ads by ProfitSence
Close

C++ asin()

Last Updated on Wednesday 5th Oct 2022

asin 2

The C++ asin() function returns the inverse sine of a number in radian.It is defined in <cmath> header file.

Syntax

			
					asin(x)

			
	

Parameters

The asin() function takes a one argument in the range [-1, 1].

Because the value of sine is in the range of 1 and -1. If the argument is out of this interval, a domain error occurs.

Return value

The asin() function returns the value in the range of [-π/2, π/2].

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

asin() prototype [As of C++ 11 standard]

			
					double asin(double x);
float asin(float x);
long double asin(long double x);
double asin (T x);

			
	

asin example

Example 1: C++ asin()

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

#define PI 3.14159265

int main () {
  double param, result;
  param = 0.44;
  result = asin(param) * 180.0 / PI;
  printf ("The arc sine of %f is %f degrees\n", param, result);
  return 0;
}

			
	

Output

			
					The arc sine of 0.440000 is 26.103881 degrees

			
	

Example 2: C++ asin() ( Argument greater than 1 )

If the argument is greater than 1 or less than -1, asin() returns NaN i.e. not a number.

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

#define PI 3.14159265

int main () {
  double param, result;
  param = 4.4;
  result = asin(param) * 180.0 / PI;
  printf ("The arc sine of %f is %f degrees\n", param, result);
  return 0;
}

			
	

Output

  • The Above Code returns NaN (Not a Number)
			
					The arc sine of 4.400000 is nan degrees

			
	

References