tan() function

The tan() function takes a single mandatory argument in radians (can be positive, negative, or 0).

The tan() function returns the value in the range of [-∞, ∞].

Example 1: In radians

Input:  radian = 0.35
Output: 0.365028

Example 2: In degrees

Input:  degrees = 60
Output: 1.72993

Approach 1: In radians

C++

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

int main()
{
    double radian = 0.35;

    cout << tan(radian);

    return 0;
}

Approach 2: In degrees

C++

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

int main()
{
    double degrees = 60;

    //convert into radians;
    double radian = degrees * 3.14 / 180;
    cout << tan(radian);

    return 0;
}


No comments:

Post a Comment