C ++ 'daki cos () işlevi, radyan cinsinden verilen bir açının (bağımsız değişken) kosinüsünü döndürür.
Bu işlev başlık dosyasında tanımlanmıştır.
(Matematik) cos x = cos (x) (C ++ Programlamada)
cos () prototipi (C ++ 11 standardından itibaren)
çift cos (çift x); float cos (float x); uzun çift cos (uzun çift x); çift cos (T x); // Burada T bir integral türüdür.
cos () Parametreler
Cos () işlevi radyan cinsinden tek bir zorunlu argüman alır.
cos () Dönüş değeri
Cos () işlevi, (-1, 1) aralığındaki değeri döndürür . Döndürülen değeri, içinde double
, float
ya da long double
.
Örnek 1: cos () C ++ 'da nasıl çalışır?
#include #include using namespace std; int main() ( double x = 0.5, result; result = cos(x); cout << "cos(x) = " << result << endl; double xDegrees = 25; // converting degrees to radians x = xDegrees*3.14159/180; result = cos(x); cout << "cos(x) = " << result << endl; return 0; )
Programı çalıştırdığınızda, çıktı:
cos (x) = 0,877583 cos (x) = 0,906308
Örnek 2: integral tipli cos () fonksiyonu
#include #include using namespace std; int main() ( int x = 1; double result; // result is in double result = cos(x); cout << "cos(x) = " << result << endl; return 0; )
Programı çalıştırdığınızda, çıktı:
cos (x) = 0,540302