acos() function

acos(): This function is available in the library math.h

Given that the argument is in the range [-1, 1], the acos() function returns the value in the 

range of [0, π].

Example 1: In radians

Input:  x=0.25
Output: 1.31812

Example 2: In degrees

Input:  degrees = 0.25
Output: 75.5608

Approach 1: In radians

C++

#include <bits/stdc++.h>
using namespace std;

int main()
{
    double x = 0.25;

    cout << acos(x);

    return 0;
}

Approach 2: In degrees

C++

#include <bits/stdc++.h>
using namespace std;

int main()
{
    double x = 0.25;

    double radian = acos(x);

    double degrees = radian * 180 / 3.14;

    cout << degrees << "\n";

    return 0;
}


No comments:

Post a Comment