asin() and atan() functions in C/C++ with Example


In C++, asin() and atan() is a predefined function used for mathematical calculations. math.h is the header file required for various mathematical functions. All the functions available in this library take double as an argument and return double as the result.

asin()

asin() function is used to find the arc sine of a number means give a sin value to this function it will return the angle in radian corresponding to that value. In trigonometrics, arc sine is the inverse operation of sine.
Note: The argument passed to this function must be between [-1, 1].



Syntax:

double asin(double k)

Parameters:
k is the value whose corresponding angle we have to find.
filter_none

edit
close

play_arrow

link
brightness_4
code

// CPP code to illustrate
// the use of asin function
#include <bits/stdc++.h>
using namespace std;
  
#define PI 3.14159265
  
int main()
{
    double k, ret, val;
  
    // Take any value between [-1, 1]
    k = 0.5;
    ret = asin(k);
    val = (ret * 180) / PI;
    cout << "The arcsine of " << k
         << " is " << ret << " radians and "
         << val << " degrees";
  
    return 0;
}

chevron_right


Output:

The arcsine of 0.5 is 0.523599 radians and 30 degrees

atan()

atan() function is used to find the arc tangent of a number means give a tangent value to this function it will return the angle in radian corresponding to that value. arc tangent is the inverse operation of tangent. This function accepts all real numbers.

Syntax:

double atan(double k)

Parameters:
k is the value whose corresponding angle we have to find.
filter_none

edit
close

play_arrow

link
brightness_4
code

// CPP code to illustrate
// the use of atan function
#include <bits/stdc++.h>
using namespace std;
  
#define PI 3.14159265
  
int main()
{
    double k, ret, val;
  
    // Take any value
    k = 1.0;
    ret = atan(k);
    val = (ret * 180) / PI;
    cout << "The arctangent of " << k
         << " is " << ret << " radians and "
         << val << " degrees";
  
    return 0;
}

chevron_right


Output:

The arctangent of 1 is 0.785398 radians and 45 degrees


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.