Syntax
#include <math.h> double asin(double x);Description
asin calculates the arcsine of x, in the range -pi/2 to pi/2 radians.
asin returns the arcsine of x. The value of x must be between -1 and 1. If x is less than -1 or greater than 1, asin sets errno to EDOM, and returns a value of 0.
This example prompts for a value for x. It prints an error message if x is greater than 1 or less than -1; otherwise, it assigns the arcsine of x to y.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define MAX 1.0
#define MIN -1.0
int main(void)
{
double x,y;
printf("Enter x\n");
scanf("%lf", &x);
/* Output error if not in range */
if (x > MAX)
printf("Error: %lf too large for asin\n", x);
else
if (x < MIN)
printf("Error: %lf too small for asin\n", x);
else {
y = asin(x);
printf("asin( %lf ) = %lf\n", x, y);
}
return 0;
/****************************************************************************
For the following input: 0.2
The output should be:
Enter x
asin( 0.200000 ) = 0.201358
****************************************************************************/
}
Related Information