Write a program for cos() function.
cos(): 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.980067
Example 2: When the angle is given in degrees
Input: degress=60
Output: 0.50046
Approach 1: When the angle is given in radians
C++
#include <bits/stdc++.h>using namespace std;int main(){double radian = 0.2;cout << cos(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 radiandouble radian = degrees * 3.14 / 180;cout << cos(radian);return 0;}
No comments:
Post a Comment