De functie sin () in C ++ retourneert de sinus van een hoek (argument) in radialen.
Deze functie is gedefinieerd in het header-bestand.
(Wiskunde) sin x = sin (x) (In C ++ programmeren)
sin () prototype (vanaf C ++ 11 standaard)
dubbele zonde (dubbele x); float sin (float x); lange dubbele zonde (lange dubbele x); dubbele zonde (T x); // Voor integraal type
sin () Parameters
De sin () functie heeft één verplicht argument in radialen.
sin () Retourwaarde
De functie sin () retourneert de waarde in het bereik van (-1, 1) . De geretourneerde waarde is ofwel in double
, float
of long double
.
Voorbeeld 1: hoe sin () werkt in C ++?
#include #include using namespace std; int main() ( double x = 0.439203, result; result = sin(x); cout << "sin(x) = " << result << endl; double xDegrees = 90.0; // converting degrees to radians x = xDegrees*3.14159/180; result = sin(x); cout << "sin(x) = " << result << endl; return 0; )
Wanneer u het programma uitvoert, is de uitvoer:
zonde (x) = 0,425218 sin (x) = 1
Voorbeeld 2: sin () functie met integraal type
#include #include using namespace std; int main() ( int x = -1; double result; result = sin(x); cout << "sin(x) = " << result << endl; return 0; )
Wanneer u het programma uitvoert, is de uitvoer:
zonde (x) = -0,841471