Funkcja tan () w C ++ zwraca tangens kąta (argumentu) podanego w radianach.
Ta funkcja jest zdefiniowana w pliku nagłówkowym.
(Matematyka) tan x = tan (x) (W programowaniu w C ++)
tan () prototyp (w standardzie C ++ 11)
podwójna opalenizna (podwójne x); float tan (float x); długa podwójna opalenizna (długi podwójny x); podwójna opalenizna (T x); // Dla typu całkowitego
tan () Parametry
Funkcja tan () przyjmuje jeden obowiązkowy argument w radianach (może być dodatni, ujemny lub 0).
tan () Wartość zwracana
Funkcja tan () zwraca wartość z zakresu (-∞, ∞) .
Przykład 1: Jak działa tan () w C ++?
#include #include using namespace std; int main() ( long double x = 0.99999, result; result = tan(x); cout << "tan(x) = " << result << endl; double xDegrees = 60.0; // converting degree to radians and using tan() fucntion result = tan(xDegrees*3.14159/180); cout << "tan(x) = " << result << endl; return 0; )
Po uruchomieniu programu wynik będzie następujący:
tan (x) = 1,55737 tan (x) = 1,73205
Przykład 2: funkcja tan () z typem całkowitym
#include #include using namespace std; int main() ( long int x = 6; double result; result = tan(x); cout << "tan(x) = " << result; return 0; )
Po uruchomieniu programu wynik będzie następujący:
tan (x) = -0,291006