C ++ cbrt () - C ++ Standardbibliothek

Die Funktion cbrt () in C ++ gibt die Kubikwurzel einer Zahl zurück.

 (Mathematik) ∛x = cbrt (x) (In C-Programmierung)

Diese Funktion ist in der Header-Datei definiert.

cbrt () Prototyp (Stand C ++ 11 Standard)

doppeltes cbrt (doppeltes x); float cbrt (float x); langes doppeltes cbrt (langes doppeltes x); Doppel-cbrt (T x); // Für integralen Typ

cbrt () Parameter

Die Funktion cbrt () verwendet ein einzelnes Argument, dessen Kubikwurzel berechnet werden soll.

cbrt () Rückgabewert

Die Funktion cbrt () gibt die Kubikwurzel des angegebenen Arguments zurück.

Beispiel 1: Wie funktioniert cbrt () in C ++?

 #include #include using namespace std; int main() ( double x = -1000.0, result; result = cbrt(x); cout << "Cube root of " << x << " is " << result << endl; return 0; ) 

Wenn Sie das Programm ausführen, lautet die Ausgabe wie folgt:

 Die Kubikwurzel von -1000 ist -10

Beispiel 2: Funktion cbrt () mit integralem Argument

 #include #include using namespace std; int main() ( long x = 964353422; double result = cbrt(x); cout << "Cube root of " << x << " is " << result << endl; return 0; ) 

Wenn Sie das Programm ausführen, lautet die Ausgabe wie folgt:

 Die Kubikwurzel von 964353422 ist 987.974

Interessante Beiträge...