sin() function

Write a program for sin() function.

sin(): It takes the single argument in radian. It returns the value in the range [-1,1]

Example 1: When the angle is given in radian

Input:  radian=0.2
Output: 0.198669

Example 2: When the angle is given in degrees

Input:  degress=60
Output: 0.86576

Approach 1: When the angle is given in radians

C++

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

int main()
{
    double radian = 0.2;

    cout << sin(radian);

    return 0;
}

Approach 2: When the angle is given in degrees

C++

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

int main()
{
    double degrees = 60;

    //convert degrees to radian
    double radian = degrees * 3.14 / 180;

    cout << sin(radian);

    return 0;
}


No comments:

Post a Comment