C asin() function

C asin() function - Calculate arcsine

The asin() function is used to calculate the arcsine of x, in the range -π/2 to π/2 radians.


double asin(double x)


Name Description Required /Optional
x Value whose arcsine is to be calculated. Required

Return value from asin()

  • Returns the arcsine (the inverse sine function) of x in the range -π/2 to π/2 radians.

Example: asin() function

The following example shows the usage of asin() function:

#include <stdio.h>
#include <stdlib.h>
#include <math.h> 
#define MAX  1.0
#define MIN -1.0 
int main(void)
  double x, y; 
  printf("Input the value of x: ");
  scanf( "%lf", &x );
  y = asin(x);
  if (x > MAX)
    printf( "Error: %lf not in the range!\n", x );
  else if (x < MIN)
    printf( "Error: %lf not in the range!\n", x );
    printf("asin(%lf) = %lf\n", x, y);


Input the value of x: 0
asin(0.000000) = 0.000000

Input the value of x: 1.5
Error: 1.500000 not in the range!

Input the value of x: -1.5
Error: -1.500000 not in the range!

C Programming Code Editor:

Previous C Programming: C acos()
Next C Programming: C atan()

Follow us on Facebook and Twitter for latest update.

C Programming: Tips of the Day

What's the point of const pointers?

const is a tool which you should use in pursuit of a very important C++ concept:

Find bugs at compile-time, rather than run-time, by getting the compiler to enforce what you mean.

Even though it does not change the functionality, adding const generates a compiler error when you're doing things you didn't mean to do. Imagine the following typo:

void foo(int* ptr)
    ptr = 0;// oops, I meant *ptr = 0

If you use int* const, this would generate a compiler error because you're changing the value to ptr. Adding restrictions via syntax is a good thing in general. Just don't take it too far -- the example you gave is a case where most people don't bother using const.

Ref : https://bit.ly/33Cdn3Q