-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3.8.cpp
More file actions
31 lines (29 loc) · 790 Bytes
/
3.8.cpp
File metadata and controls
31 lines (29 loc) · 790 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<iostream>
#include<cmath>
using namespace std;
const double pi=3.14;
int main() {
double degress, radian,sinvalue, cosvalue, tanvalue, cotvalue;
cout<<"nhap goc do: ";
cin>>degress;
//chuyen do sang radian
radian=degress*pi/180;
sinvalue= sin(radian);
cosvalue= cos(radian);
tanvalue= tan(radian);
// kiem tra gia tri cua tan, khong the tinh neu tan = 0
if(tanvalue !=0) {
cotvalue= 1/tanvalue;
}else {
cotvalue= NAN;
}
cout << "sin(" << degress << "°) = " << sinvalue <<endl;
cout << "cos(" << degress << "°) = " << cosvalue <<endl;
cout << "tan(" << degress << "°) = " << tanvalue <<endl;
if(!isnan(cotvalue)) {
cout << "cot(" << degress << "°) = " << cotvalue <<endl;
}else {
cout << "cot(" << degress << "°) khong xac dinh" <<endl;
}
return 0;
}