Min menu

Pages

VB

Numbers in C Plus Plus C++

 Numbers in C Plus Plus C++

There are a lot of ready-made functions inC++ To deal with the setup in C-Plus which you can use to perform calculations.
Some of these functions can be used directly because they are known to the language translator by default and some functions need to be included by yourself first to be able to use them.

In general, to be able to use custom functions to perform calculations, you must include the file cmaththat contains them.
So you will find that we will add the following line in any example we use one of the functions that we will learn in this lesson.

#include <cmath>
	

This line means that we want to add the content of the file cmathin the program so that we can use the functions in it.

Numerology in C++ There are tons of ready-made functions in C++ that you can use to perform mathematical operations. Some of these functions can be used directly because they are known to the language compiler by default, and some functions need to be included by yourself first in order to be able to use them. In general, in order to be able to use the functions assigned to perform the calculations, you must include the cmath file that contains it. Therefore, you will find that we will add the following line in any example in which we use one of the functions that we will learn in this lesson. #include <cmath> This line means that we want to add the content of the cmath file in the program, which makes us able to use the functions in it.


File functions cmath to deal with the setting in C++  C++

The following table contains the cmathmost commonly used file functions to deal with setup in C++.

Function name and definition
abs(x) Returns the absolute value (Absolte Value)For the number we pass it has the place of the parameterx.
Explanation of the abs() function in C++
fabs(x)Returns the absolute value of the number of its type floatthat we pass to it in the place of the parameterx.
Explanation of the fabs() function in C++
floor(x) Returns the integer smaller or equal to the number we pass to it in the place of the parameterx.
Explanation of the floor() function in C++
ceil(x) Returns the integer greater or equal to the number we pass to it in the place of the parameterx.
Explanation of the ceil() function in C++
rint(x) Returns the closest integer to the number we pass to it in place of the parameterx.
rint() function in C++
fmax(x, y) Returns the greater of the two numbers we pass in place of the two parameters xandy.
The fmax() function in C++
fmin(x, y) Returns the smallest number between the two numbers we pass in place of the two parameters xandy.
The fmin() function in C++
fmod(x, y) Returns the number that remains from dividing the value of the parameter xby the value of the parametery.
The fmod() function in C++
pow(x, y) Multiply the parameter value by the parameter xvalue yand return the result.
pow() function in C++
sqrt(x) Returns the value of the squared islands (Square Root)The number we pass has the place of the parameterx.
sqrt() function in C++
cbrt(x) Returns the value of the cubic carrot (Cube Root)The number we pass has the place of the parameterx.
cbrt() function in C++
fdim(x, y) If a value xis greater than a value y, the difference between them is returned, which is equal tox-y,Noting that it always returns the difference as a positive number(Positive Number).
Otherwise, it returns zero, whatever the value of the numbers entered.
The fdim() function in C++
fma(x, y, z) Returns a value x * y + zwhile preserving any number after the comma.
function fma() in C++
hypot(x, y) Returns the value of the hypotenuse (Hypotenuse).
That is, it returns a value sqrt(x2 +y2)while preserving any number after the comma.
hypot() function in C++
exp(x) Returns the value of e x , that is, the value of the acceleration (Exponential)The number we pass has the place of the parameterx.
The exp() function in C++
expm1(x) Returns the value of e x - 1 , that is, the value of the acceleration (Exponential)The number that we pass has the place of the parameter xminus one.
function expm1() in C++ log(x) Returns the value of log e (x) , ie the value of the logarithm (Logarithm)The number we pass has the place of the parameterx.
log() function in C++ log2(x) Returns the value of log 2 (x) , ie the value of the binary logarithm (Binary Logarithm)The number we pass has the place of the parameterx.
The log2() function in C++ log10(x) Returns the value of log 10 (x) , ie the value of the decimal logarithm (Decimal Logarithm)The number we pass has the place of the parameterx.
The log10() function in C++ sin(x) Returns the value of sine or sine (Sin)The number we pass has the place of the parameterx.
sin() function in C++ asin(x) Returns the value of the inverse sine or arc sine (Arc Sine)The number we pass has the place of the parameterx.
The asin() function in C++ asinh(x) Returns the value of the hyperbolic sine or hyperbolic sine (Hyperbolic Sine)The number we pass has the place of the parameterx.
The asinh() function in C++ cos(x) Returns the value of the cosine (Cosine)The number we pass has the place of the parameterx.
cos() function in C++ acos(x) Returns the value of inverse cosine or arc cosine (Arc Cosine)The number we pass has the place of the parameterx.
The acos() function in C++ cosh(x) Returns the value of the hyperbolic cosine (Hyperbolic Cosine)The number we pass has the place of the parameterx.
The cosh() function in C++ tan(x)Returns the tangent , tangent , or tangent value (Tangent)The number we pass has the place of the parameterx.
The tan() function in C++ atan(x) Returns the value of the inverse tangent or arctan tangent (Arc Tangent)The number we pass has the place of the parameterx.
The atan() function in C++ tanh(x) Returns the value of the hyperbolic tangent or hyperbolic tangent (Hyperbolic Tangent)The number we pass has the place of the parameterx.
The tanh() function in C++

note

It is enough just to know that the functions we mentioned are available to be used when you need them in the future.
It is natural that most of these functions may not have passed you before because these functions are mostly used in arithmetic operations that are taught in mathematics and physics, so most likely you may not use most of the functions mentioned in regular programs.

Note It is enough just to know that the functions we mentioned are available for you to use when you need them in the future. It is natural that most of these functions have not passed with you before because these functions are used mostly in mathematical operations studied in mathematics and physics, so it is likely that most of the mentioned functions in regular programs may not be used.


How to generate random numbers inC++

In many cases you may need to generate random number values ​​in your programs and you may need to specify the range of random numbers you want to generate, for example in a game of dice you may want to get a random value between 1 and 6.

In many cases, you may need to generate random values ​​in your programs, and you may need to define the range of random numbers that you want to generate, for example in the dice game you may want to obtain a random value between 1 and 6.

function rand() in C++

To get a random number, you can use a function named rand()in the file stdlib.has follows.

The rand () function in C ++ To get a random number, you can use a function called rand () in the stdlib.h file as follows.

first example

Main.cpp
#include <iostream>
#include <stdlib.h>

using namespace std;

int main()
{
	// Here we have printed a random number
    cout << "Random number: " << rand();
    
	return 0;
}
		

We will get a random result that looks like the following when running.

Random number: 41
		

If we run the program again, we will get the same previous result as follows.

Random number: 41
		

If we run the program a third time, we will get the same previous result as follows.

Random number: 41
		

So using the function rand()alone does not guarantee that you will get a different random number each time you run the program.
Precisely for this reason, you should learn a language translatorC++That it re-changes the random probabilities when the program is run and before the function is called rand(), and this is what we will learn now.


Functions srand()and time() in C++

The function srand()is used to change the string of random values ​​that will be generated when the function is called rand()making you get different random values ​​from the ones you got the last time you ran the program.

By default, the function rand()uses the range srand(1)every time the program is run, so we get the same random values ​​as the program.

To pass a different number to the function srand()automatically, you can pass the number of seconds present from 1-1-1970and to the current device time and this you get by calling the function time(0)and passing it to the function srand()as we will see in the following example.

Note: To use the function srand(), you must include the file stdlib.h, and to use the function time(), you must include the filetime.h.

second example

Main.cpp
#include <iostream>
#include <stdlib.h>
#include <time.h>

using namespace std;

int main()
{
	// Here we have changed the series of random values ​​that will be generated
	srand(time(0));
	
	// Here we have printed a random number
    cout << "Random number: " << rand();
    
	return 0;
}
		

We will get a random result that looks like the following when running.

Random number: 1537
		

If we run the program a second time, we will get a random result different from the previous result as follows.

Random number: 1579
		

If we run the program a third time, we will get a random result different from the previous result as follows.

Random number: 1621
		

The following example demonstrates how to specify the highest and lowest random value that can be returned.

third example

Main.cpp
#include <iostream>
#include <stdlib.h>
#include <time.h>

using namespace std;

int main()
{
    // Here we have changed the series of random values ​​that will be generated
    srand(time(0));

	// Here we have generated a random number between 1 and 10
    int x = rand() %10 + 1;

    // Here we have printed a random number
    cout << "Random number: " << x;

    return 0;
}

		

We will get a random number between 1and 10as follows when running.

Random number: 3
		
______

function abs() in C++

Definition of the function  abs() in C++

Returns the absolute value (Absolte Value)For the number we pass it has the place of the parameterx.

Define the abs() function in C++ Absoulte value returns to the number we pass to it in place of the parameter x.

build the function  abs() in C++

There are several variants of this function where values ​​of various types can be passed to it.

                  // first figure
                  double abs (double x)

                  // the second figure
                  float abs (float x)

                  // the third figure
                  long double abs (long double x)
                
                  // first figure
                  double abs (double x)

                  // the second figure
                  float abs (float x)

                  // the third figure
                  long double abs (long double x)

                  // fourth figure
                  double abs (T x)
                


Parameters of the function  abs() in C++

The place of the parameter xwe pass its type number doubleor floatorlong double.



The return value of the function  abs() in C++

Returns the absolute value of the number we pass in the place of the parameter xand returns it of the same type.
That is, if you pass it the value of its type double, you are calling the first function that returns an absolute value of its typedouble.



function example  abs() in C++

Main.cpp
                    #include <iostream>
                    using namespace std;

                    int main()
                    {
                    double a = -130;
                    float b = -0.15;
                    long double c = -5;

                    cout << "abs(a) = " << abs(a) << endl;
                    cout << "abs(b) = " << abs(b) << endl;
                    cout << "abs(c) = " << abs(c) << endl;

                    return 0;
                    }
                  

We will get the following result when running.

                    abs(a) = 130
                    abs(b) = 0.15
                    abs(c) = 5
                  
_______

function fabs() in C++

Definition of the function  fabs() in C++

Returns the absolute value (Absolute Value)For the number we pass it has the place of the parameterx.

Note: This function is in the file <cmath>, so it must be included so that we can call it.


Define the fabs() function in C++ Absolute value returns to the number we pass to it in place of the parameter x. Note: This function is in the file <cmath>, so it must be included in order to be able to call it.

build the function  fabs() in C++

There are several variants of this function where values ​​of various types can be passed to it.

                  // first figure
                  double fabs (double x)

                  // the second figure
                  float fabs (float x)

                  // the third figure
                  long double fabs (long double x)
                
                  // first figure
                  double fabs (double x)

                  // the second figure
                  float fabs (float x)

                  // the third figure
                  long double fabs (long double x)

                  // fourth figure
                  double fabs (T x)
                


Parameters of the function  fabs() in C++

The place of the parameter xwe pass its type number doubleor floatorlong double.



The return value of the function  fabs() in C++

Returns the absolute value of the number we pass in the place of the parameter xand returns it of the same type.
That is, if you pass it the value of its type double, you are calling the first function that returns an absolute value of its typedouble.



function example  fabs() in C++

Main.cpp
                    #include <iostream>
                    #include <cmath>

                    using namespace std;

                    int main()
                    {
                    double a = -130;
                    float b = -0.15;
                    long double c = -5;

                    cout << "fabs(a) = " << fabs(a) << endl;
                    cout << "fabs(b) = " << fabs(b) << endl;
                    cout << "fabs(c) = " << fabs(c) << endl;

                    return 0;
                    }
                  

We will get the following result when running.

                    fabs(a) = 130
                    fabs(b) = 0.15
                    fabs(c) = 5
                  
_______

function floor() in C++

Definition of the function  floor() in C++

Returns the integer smaller or equal to the number we pass to it in the place of the parameterx.

Note: This function is in the file <cmath>, so it must be included so that we can call it.

Define the floor() function in C++ Returns the integer smaller or equal to the number we pass to it in the place of the parameter x. Note: This function is already in the file <cmath>, so it must be included in order to call it.

build the function  floor() in C++

There are several variants of this function where values ​​of various types can be passed to it.

                  // first figure
                  double floor (double x)

                  // the second figure
                  float floor (float x)

                  // the third figure
                  long double floor (long double x)
                
                  // first figure
                  double floor (double x)

                  // the second figure
                  float floor (float x)

                  // the third figure
                  long double floor (long double x)

                  // fourth figure
                  double floor (T x)
                


Parameters of the function  floor() in C++

The place of the parameter xwe pass its type number doubleor floatorlong double.



The return value of the function  floor() in C++

Returns the integer smaller or equal to the number we pass to it in the place of the parameter xand returns it of the same type.
That is, if you pass it the value of its type double, then you call the first function that returns the value of its typedouble.



function example  floor() in C++

Main.cpp
                    #include <iostream>
                    #include <cmath>

                    using namespace std;

                    int main()
                    {
                    float a = 5.5;
                    float b = -3.9;

                    cout << "floor value of " << a << " is: " << floor(a) << endl;
                    cout << "floor value of " << b << " is: " << floor(b) << endl;

                    return 0;
                    }
                  

We will get the following result when running.

                    floor value of 5.5 is: 5
                    floor value of -3.9 is: -4
                  
_______

function ceil() in C++

Definition of the function  ceil() in C++

Returns the integer greater or equal to the number we pass to it in the place of the parameterx.

Note: This function is in the file <cmath>, so it must be included so that we can call it.

Defining the ceil() function in C++ Returns the larger integer or equal to the number we pass to it in the place of the parameter x. Note: This function is already in the file <cmath>, so it must be included in order to call it.

build the function  ceil() in C++

There are several variants of this function where values ​​of various types can be passed to it.

                  // first figure
                  double ceil (double x)

                  // the second figure
                  float ceil (float x)

                  // the third figure
                  long double ceil (long double x)
                
                  // first figure
                  double ceil (double x)

                  // the second figure
                  float ceil (float x)

                  // the third figure
                  long double ceil (long double x)

                  // fourth figure
                  double ceil (T x)
                


Parameters of the function  ceil() in C++

The place of the parameter xwe pass its type number doubleor floatorlong double.



The return value of the function  ceil() in C++

Returns the integer greater or equal to the number we pass to it in the place of the parameter xand returns it of the same type.
That is, if you pass it the value of its type double, then you call the first function that returns the value of its typedouble.



function example  ceil() in C++

Main.cpp
                    #include <iostream>
                    #include <cmath>

                    using namespace std;

                    int main()
                    {
                    float a = 5.5;
                    float b = -3.9;

                    cout << "ceil value of " << a << " is: " << ceil(a) << endl;
                    cout << "ceil value of " << b << " is: " << ceil(b) << endl;

                    return 0;
                    }
                  

We will get the following result when running.

                    ceil value of 5.5 is: 6
                    ceil value of -3.9 is: -3
                  
________

function rint() in C++

Definition of the function  rint() in C++

Returns the closest integer to the number we pass to it in place of the parameterx.

Note: This function is in the file <cmath>, so it must be included so that we can call it.

Define the rint() function in C++ Returns the nearest integer to the number we pass to it in the place of the parameter x. Note: This function is already in the file <cmath>, so it must be included in order to call it.

build the function  rint() in C++

There are several variants of this function where values ​​of various types can be passed to it.

                  // first figure
                  double rint (double x)

                  // the second figure
                  float rint (float x)

                  // the third figure
                  long double rint (long double x)

                  // fourth figure
                  double rint (T x)
                


Parameters of the function  rint() in C++

The place of the parameter xwe pass its type number doubleor floatorlong double.



The return value of the function  rint() in C++

Returns the closest integer to the number we pass to it in place of the parameter xand returns it of the same type.
That is, if you pass it the value of its type double, then you call the first function that returns the value of its typedouble.



function example  rint() in C++

Main.cpp
                    #include <iostream>
                    #include <cmath>

                    using namespace std;

                    int main()
                    {
                    float a = 5.5;
                    float b = 5.2;
                    float c = -3.9;
                    float d = -3.3;

                    cout << "Round int value of " << a << " is: " << rint(a) << endl;
                    cout << "Round int value of " << b << " is: " << rint(b) << endl;
                    cout << "Round int value of " << c << " is: " << rint(c) << endl;
                    cout << "Round int value of " << d << " is: " << rint(d) << endl;

                    return 0;
                    }
                  

We will get the following result when running.

                    Round int value of 5.5 is: 6
                    Round int value of 5.2 is: 5
                    Round int value of -3.9 is: -4
                    Round int value of -3.3 is: -3
                  
______

function fmax() in C++

Definition of the function  fmax() in C++

Returns the greater of the two numbers we pass in place of the two parameters xandy.

Note: This function is in the file <cmath>, so it must be included so that we can call it.

Define the fmax () function in C ++ The largest number between the two numbers we pass to returns the place of the two parameters x and y. Note: This function is in the file <cmath>, so it must be included in order to be able to call it.

build the function  fmax() in C++

There are four forms of this function. That is, it can be called in four different ways.

                  // first figure
                  double fmax (double x, double y)

                  // the second figure
                  float fmax (float x, float y)

                  // the third figure
                  long double fmax (long double x, long double y);

                  // fourth figure
                  double fmax (T1 x, T2 y);
                


Parameters of the function  fmax() in C++

Two integers of any kind can be passed to it when called in place of the two parameters x, yand a language translator will doC++Calls the appropriate function for the type of values ​​you passed.



The return value of the function  fmax() in C++

Returns the larger number between the two numbers that we pass to it in the place of the parameter xand yreturns it according to the type of the larger number.



function example  fmax() in C++

Main.cpp
                    #include <iostream>
                    #include <cmath>

                    using namespace std;

                    int main()
                    {
                    int a = 7;
                    float b = 20.5;

                    cout << "Max number is: " << fmax(a, b);

                    return 0;
                    }
                  

We will get the following result when running.

                    Max number is: 20.5
                  
_________

function fmin() in C++

Definition of the function  fmin() in C++

Returns the smallest number between the two numbers we pass in place of the two parameters xandy.

Note: This function is in the file <cmath>, so it must be included so that we can call it.

Define the fmin() function in C++ The smaller number between the two we pass to it returns the place of the two parameters x and y. Note: This function is in the file <cmath>, so it must be included in order to be able to call it.

build the function  fmin() in C++

There are four forms of this function. That is, it can be called in four different ways.

                  // first figure
                  double fmin (double x, double y)

                  // the second figure
                  float fmin (float x, float y)

                  // the third figure
                  long double fmin (long double x, long double y);

                  // fourth figure
                  double fmin (T1 x, T2 y);
                


Parameters of the function  fmin() in C++

Two integers of any kind can be passed to it when called in place of the two parameters x, yand a language translator will doC++Calls the appropriate function for the type of values ​​you passed.



The return value of the function  fmin() in C++

Returns the smallest number between the two numbers we pass to it in the place of the two parameters x, yand returns it according to the type of the smaller number.



function example  fmin() in C++

Main.cpp
                    #include <iostream>
                    #include <cmath>

                    using namespace std;

                    int main()
                    {
                    int a = 7;
                    float b = 20.5;

                    cout << "Min number is: " << fmin(a, b);

                    return 0;
                    }
                  

We will get the following result when running.

                    Min number is: 7
                  
_______

function fmod() in C++

Definition of the function  fmod() in C++

Returns the number that remains from dividing the value of the parameter xby the value of the parametery.

Note: This function is in the file <cmath>, so it must be included so that we can call it.


Define the fmod() function in C++ Returns the number left over from dividing the parameter value x by the parameter value y. Note: This function is in the file <cmath>, so it must be included in order to be able to call it.

build the function  fmod() in C++

There are four forms of this function. That is, it can be called in four different ways.

                  // first figure
                  double fmod (double x, double y)

                  // the second figure
                  float fmod (float x, float y)

                  // the third figure
                  long double fmod (long double x, long double y);

                  // fourth figure
                  double fmod (T1 x, T2 y);
                


Parameters of the function  fmod() in C++

Two integers of any kind can be passed to it when called in place of the two parameters x, yand a language translator will doC++Calls the appropriate function for the type of values ​​you passed.



The return value of the function  fmod() in C++

Returns the number that remains from dividing the value of the parameter xby the value of the parameter yand returns it according to the type of values ​​passed.



function example  fmod() in C++

Main.cpp
                    #include <iostream>
                    #include <cmath>

                    using namespace std;

                    int main()
                    {
                    int a = 10;
                    int b = 7;

                    cout << a << " % " << b << " = " << fmod(a, b);

                    return 0;
                    }
                  

We will get the following result when running.

                    10 % 7 = 3
                  
_________

function pow() in C++

Definition of the function  pow() in C++

Multiply the parameter value by the parameter xvalue yand return the result.

Note: This function is in the file <cmath>, so it must be included so that we can call it.

Define the pow() function in C++ Multiply the parameter value x by the value of the parameter y and then return the result. Note: This function is already in the file <cmath>, so it must be included in order to call it.

build the function  pow() in C++

There are several variants of this function where values ​​of various types can be passed to it.

                  // first figure
                  double pow (double x, double y)

                  // the second figure
                  float pow (float x, float y)

                  // the third figure
                  long double pow (long double x, long double y)

                  // fourth figure
                  double pow (double x, int y)

                  // the fifth form
                  long double pow (long double x, int y)
                
                  // first figure
                  double pow (double x, double y)

                  // the second figure
                  float pow (float x, float y)

                  // the third figure
                  long double pow (long double x, long double y)

                  // fourth figure
                  double pow (T1 x, T2 y)
                


Parameters of the function  pow() in C++

Two integers of any kind can be passed to it when called in place of the two parameters x, yand a language translator will doC++Calls the appropriate function for the type of values ​​you passed.



The return value of the function  pow() in C++

The result of doubling the parameter value returns the parameter xvalue yand returns it of the same type as the values ​​that were passed to it.
That is, if you pass it the values ​​of its type double, you call the first function that returns the result of its typedouble.



function example  pow() in C++

Main.cpp
                    #include <iostream>
                    #include <cmath>

                    using namespace std;

                    int main()
                    {
                    float a = 5;
                    float b = 2;

                    cout << a << " ^ " << b << " = " << pow(a, b);

                    return 0;
                    }

                  

We will get the following result when running.

                    5^2 = 25
                  
___________

function sqrt() in C++

Definition of the function  sqrt() in C++

Returns the value of the squared islands (Square Root)The number we pass has the place of the parameterx.

Note: This function is in the file <cmath>, so it must be included so that we can call it.

Define the sqrt() function in C++ The square root of the number we pass to it returns the place of the parameter x. Note: This function is already in the file <cmath>, so it must be included in order to call it.

build the function  sqrt() in C++

There are several variants of this function where values ​​of various types can be passed to it.

                  // first figure
                  double sqrt (double x)

                  // the second figure
                  float sqrt (float x)

                  // the third figure
                  long double sqrt (long double x)
                
                  // first figure
                  double sqrt (double x)

                  // the second figure
                  float sqrt (float x)

                  // the third figure
                  long double sqrt (long double x)

                  // fourth figure
                  double sqrt (T x)
                


Parameters of the function  sqrt() in C++

The place of the parameter xwe pass its type number doubleor floatorlong double.



Return value of the function  sqrt() in C++

Returns the squared islands value of the number we pass to it in the place of the parameter xand returns it of the same type.
That is, if you pass it the value of its type double, then you call the first function that returns the value of its typedouble.



 

function example  sqrt() in C++

Main.cpp
                    #include <iostream>
                    #include <cmath>

                    using namespace std;

                    int main()
                    {
                    float x = 25;

                    cout << "The square root of " << x << " is: " << sqrt(x);

                    return 0;
                    }
                  

We will get the following result when running.

                    The square root of 25 is: 5
                  
_________

function cbrt() in C++

Definition of the function  cbrt() in C++

Returns the value of the cubic carrot (Cube Root)The number we pass has the place of the parameterx.

Note: This function is in the file <cmath>, so it must be included so that we can call it.

Define the cbrt() function in C++ The value of the cube root returns the number we pass to it in the place of the parameter x. Note: This function is already in the file <cmath>, so it must be included in order to call it.

build the function  cbrt() in C++

There are several variants of this function where values ​​of various types can be passed to it.

                  // first figure
                  double cbrt (double x)

                  // the second figure
                  float cbrt (float x)

                  // the third figure
                  long double cbrt (long double x)
                
                  // first figure
                  double cbrt (double x)

                  // the second figure
                  float cbrt (float x)

                  // the third figure
                  long double cbrt (long double x)

                  // fourth figure
                  double cbrt (T x)
                


Parameters of the function  cbrt() in C++

The place of the parameter xwe pass its type number doubleor floatorlong double.



Return value of the function  cbrt() in C++

Returns the value of the cube islands of the number that we pass to it in the place of the parameter xand returns it of the same type.
That is, if you pass it the value of its type double, then you call the first function that returns the value of its typedouble.



function example  cbrt() in C++

Main.cpp
                    #include <iostream>
                    #include <cmath>

                    using namespace std;

                    int main()
                    {
                    float x = 8;

                    cout << "The cube root of " << x << " is: " << cbrt(x);

                    return 0;
                    }
                  

We will get the following result when running.

                    The cube root of 8 is: 2
                  
________

function fdim() in C++

Definition of the function  fdim() in C++

If a value xis greater than a value y, the difference between them is returned, which is equal tox-y,Noting that it always returns the difference as a positive number(Positive Number).
Otherwise, it returns zero, whatever the value of the numbers entered.

Note: This function is in the file <cmath>, so it must be included so that we can call it.

Define the fdim() function in C++ If the value of x is greater than the value of y, it is the difference between them, which is equal to xy, indicating that it returns the difference as an always positive number (Positive Number ). Otherwise, it returns zero, regardless of the value of the entered numbers. Note: This function is in the file <cmath>, so it must be included in order to be able to call it.

build the function  fdim() in C++

There are four forms of this function. That is, it can be called in four different ways.

                  // first figure
                  double fdim (double x, double y)

                  // the second figure
                  float fdim (float x, float y)

                  // the third figure
                  long double fdim (long double x, long double y);

                  // fourth figure
                  double fdim (T1 x, T2 y);
                


Parameters of the function  fdim() in C++

Two integers of any kind can be passed to it when called in place of the two parameters x, yand a language translator will doC++Calls the appropriate function for the type of values ​​you passed.



The return value of the function  fdim() in C++

Returns a number greater than zero representing the difference between the two numbers we pass to it in the place of the parameters xand yand returns it depending on the type of values ​​passed.



function example  fdim() in C++

Main.cpp
                    #include <iostream>
                    #include <cmath>

                    using namespace std;

                    int main()
                    {
                    int a = 5;
                    int b = -2;

                    cout << "Positive difference between " << a << " and " << b << " is: " << fdim(a, b);

                    return 0;
                    }
                  

We will get the following result when running.

                    Positive difference between 5 and -2 is: 7
                  
_______

function fma() in C++

Definition of the function  fma() in C++

Returns a value x * y + zwhile preserving any number after the comma.

Note: This function is in the file <cmath>, so it must be included so that we can call it.


Defining the fma() function in C++ Returns the value x * y + z keeping any number after the comma. Note: This function is already in the file <cmath>, so it must be included in order to be able to call it

build the function  fma() in C++

There are four forms of this function. That is, it can be called in four different ways.

                  // first figure
                  double fma (double x, double y, double z)

                  // the second figure
                  float fma (float x, float y, float z)

                  // the third figure
                  long double fma (long double x, long double y, long double z);

                  // fourth figure
                  double fma (T1 x, T2 y, T3 z);
                


Function parameters fma() in C++

Three numbers of any kind can be passed to it when called in place of the parameters x, yand z a language translator will runC++Calls the appropriate function for the type of values ​​you passed.



Function return value fma() in C++

Returns a value x * y + zkeeping any number after the comma and returns it depending on the type of values ​​passed.



Function example fma() in C++

Main.cpp
                    #include <iostream>
                    #include <cmath>

                    using namespace std;

                    int main()
                    {
                    int a = 5;
                    float b = 2;
                    double c = 3;

                    cout << a << " * " << b << " + " << c << " = " << fma(a, b, c);

                    return 0;
                    }

                  

We will get the following result when running.

                    5 * 2 + 3 = 13
                  
______

Functionhypot() in C++

Function definition hypot() in C++

Returns the value of the hypotenuse (Hypotenuse).
That is, it returns a value sqrt(x2 +y2)while preserving any number after the comma.

Note: This function is in the file <cmath>, so it must be included so that we can call it.


Define the hypot() function in C++ Returns the value of the hypotenuse (Hypotenuse). That is, it returns sqrt (x2 + y2) while preserving any digit after the comma. Note: This function is already in the file <cmath>, so it must be included in order to call it.

build the function  hypot() in C++

There are several variants of this function where values ​​of various types can be passed to it.

                  // first figure
                  double hypot (double x, double y)

                  // the second figure
                  float hypot (float x, float y)

                  // the third figure
                  long double hypot (long double x, long double y)

                  // fourth figure
                  double hypot (T1 x, T2 y)
                


Parameters of the function  hypot() in C++

Two integers of any kind can be passed to it when called in place of the two parameters x, yand a language translator will doC++Calls the appropriate function for the type of values ​​you passed.



The return value of the function  hypot() in C++

Returns a value sqrt(x2 +y2)while preserving any number after the comma and returns it of the same type as the values ​​passed to it.
That is, if you pass it the values ​​of its type double, you call the first function that returns the result of its typedouble.



function example  hypot() in C++

 

Main.cpp
                    #include <iostream>
                    #include <cmath>

                    using namespace std;

                    int main()
                    {
                    float a = 5;
                    float b = 2;
                    float c = hypot(a, b);

                    cout << "c = " << c;

                    return 0;
                    }

                  

We will get the following result when running.

                    c = 5.38516
                  
_______

function exp() in C++

Definition of the function  exp() in C++

Returns the value of e x , that is, the value of the acceleration (Exponential)The number we pass has the place of the parameterx.

Note: This function is in the file <cmath>, so it must be included so that we can call it.

Define the exp() function in C++ Returns the value of ex, that is, the exponential value of the number we pass to it in place of the parameter x. Note: This function is already in the file <cmath>, so it must be included in order to call it.

build the function  exp() in C++

There are several variants of this function where values ​​of various types can be passed to it.

                  // first figure
                  double exp (double x)

                  // the second figure
                  float exp (float x)

                  // the third figure
                  long double exp (long double x)
                
                  // first figure
                  double exp (double x)

                  // the second figure
                  float exp (float x)

                  // the third figure
                  long double exp (long double x)

                  // fourth figure
                  double exp (T x)
                


Parameters of the function  exp() in C++

The place of the parameter xwe pass its type number doubleor floatorlong double.



The return value of the function  exp() in C++

Returns a value that is a emultiple of the parameter value xand returns it of the same type.
That is, if you pass it the value of its type double, then you call the first function that returns the value of its typedouble.



function example  exp() in C++

Main.cpp
                    #include <iostream>
                    #include <cmath>

                    using namespace std;

                    int main()
                    {
                    double x = 0.5;

                    cout << "e ^ " << x << " = " << exp(x);

                    return 0;
                    }
                  

We will get the following result when running.

                    e ^ 0.5 = 1.64872
                  
_________

function expm1() in C++

Definition of the function  expm1() in C++

Returns the value of e x - 1 , that is, the value of the acceleration (Exponential)The number that we pass has the place of the parameter xminus one.

Note: This function is in the file <cmath>, so it must be included so that we can call it.

Define the expm1() function in C++ Returns the value of ex - 1, that is, the exponential value of the number we pass to it in place of the parameter x minus one. Note: This function is already in the file <cmath>, so it must be included in order to call it.

build the function  expm1() in C++

There are several variants of this function where values ​​of various types can be passed to it.

                  // first figure
                  double expm1 (double x)

                  // the second figure
                  float expm1 (float x)

                  // the third figure
                  long double expm1 (long double x)
                
                  // first figure
                  double expm1 (double x)

                  // the second figure
                  float expm1 (float x)

                  // the third figure
                  long double expm1 (long double x)

                  // fourth figure
                  double expm1 (T x)
                


Parameters of the function  expm1() in C++

The place of the parameter xwe pass its type number doubleor floatorlong double.



The return value of the function  expm1() in C++

Returns a value emultiplied by the value of the parameter xminus one, and returns it of the same type.
That is, if you pass it the value of its type double, then you call the first function that returns the value of its typedouble.



function example  expm1() in C++

Main.cpp
                    #include <iostream>
                    #include <cmath>

                    using namespace std;

                    int main()
                    {
                    double x = 0.5;

                    cout << "(e ^ " << x << " ) - 1 = " << expm1(x);

                    return 0;
                    }
                  

We will get the following result when running.

                    (e ^ 0.5 ) - 1 = 0.648721
                  
_________

function log() in C++

Definition of the function  log() in C++

Returns the value of log e (x) , ie the value of the logarithm (Logarithm)The number we pass has the place of the parameterx.

Note: This function is in the file <cmath>, so it must be included so that we can call it.

Define the log() function in C++ The value of log (x), that is, the logarithm value of the number we pass to it, returns the value of the parameter x. Note: This function is already in the file <cmath>, so it must be included in order to call it.

build the function  log() in C++

There are several variants of this function where values ​​of various types can be passed to it.

                  // first figure
                  double log (double x)

                  // the second figure
                  float log (float x)

                  // the third figure
                  long double log (long double x)
                
                  // first figure
                  double log (double x)

                  // the second figure
                  float log (float x)

                  // the third figure
                  long double log (long double x)

                  // fourth figure
                  double log (T x)
                


Parameters of the function  log() in C++

The place of the parameter xwe pass its type number doubleor floatorlong double.



Return value of the function  log() in C++

Returns the value of the natural logarithm of the parameter xand returns it of the same type.
That is, if you pass it the value of its type double, then you call the first function that returns the value of its typedouble.



Function example log() in C++

Main.cpp
                    #include <iostream>
                    #include <cmath>

                    using namespace std;

                    int main()
                    {
                    double x = 5.5;

                    cout << "log(" << x << ") = " << log(x);

                    return 0;
                    }
                  

We will get the following result when running.

                    log(5.5) = 1.70475
                  
________

function log2() in C++

Definition of the function  log2() in C++

Returns the value of log2 2 (x) , ie the value of the binary logarithm (Binary Logarithm)The number we pass has the place of the parameterx.

Note: This function is in the file <cmath>, so it must be included so that we can call it.

Define the log2() function in C++ The value of log22 (x), that is, the binary logarithm of the number we pass it to, returns the value of the parameter x. Note: This function is in the file <cmath>, so it must be included in order to be able to call it.

build the function  log2() in C++

There are several variants of this function where values ​​of various types can be passed to it.

                  // first figure
                  double log2 (double x)

                  // the second figure
                  float log2 (float x)

                  // the third figure
                  long double log2 (long double x)
                
                  // first figure
                  double log2 (double x)

                  // the second figure
                  float log2 (float x)

                  // the third figure
                  long double log2 (long double x)

                  // fourth figure
                  double log2 (T x)
                


Function parameters log2() in C++

The place of the parameter xwe pass its type number doubleorfloatorlong double.



Function return value log2() in C++

Returns the binary logarithm of a parameter xand returns it of the same type.
That is, if you pass it the value of its type double, then you call the first function that returns the value of its typedouble.



Function example log2() in C++

Main.cpp
                    #include <iostream>
                    #include <cmath>

                    using namespace std;

                    int main()
                    {
                    double x = 5.5;

                    cout << "log2(" << x << ") = " << log2(x);

                    return 0;
                    }
                  

We will get the following result when running.

                    log2(5.5) = 2.45943
                  
_______

function log10() in C++

Definition of the function  log10() in C++

Returns the value of log 10 (x) , ie the value of the decimal logarithm (Decimal Logarithm)The number we pass has the place of the parameterx.

Note: This function is in the file <cmath>, so it must be included so that we can call it.

Note: This function is in the file <cmath>, so it must be included in order to be able to call it.

build the function  log10() in C++

There are several variants of this function where values ​​of various types can be passed to it.

                  // first figure
                  double log10 (double x)

                  // the second figure
                  float log10 (float x)

                  // the third figure
                  long double log10 (long double x)
                
                  // first figure
                  double log10 (double x)

                  // the second figure
                  float log10 (float x)

                  // the third figure
                  long double log10 (long double x)

                  // fourth figure
                  double log10 (T x)
                


Parameters of the function  log10() in C++

The place of the parameter xwe pass its type number doubleor floatorlong double.



The return value of the function  log10() in C++

Returns the decimal logarithm value of the parameter xand returns it of the same type.
That is, if you pass it the value of its type double, then you call the first function that returns the value of its typedouble.



function example  log10() in C++

Main.cpp
                    #include <iostream>
                    #include <cmath>

                    using namespace std;

                    int main()
                    {
                    double x = 1000;

                    cout << "log10(" << x << ") = " << log10(x);

                    return 0;
                    }
                  

We will get the following result when running.

                    log10(1000) = 3
                  
_____

function sin() in C++

Definition of the function  sin() in C++

Returns the value of sine or sine (Sin)The number we pass has the place of the parameterx.

Note: This function is in the file <cmath>, so it must be included so that we can call it.

Define the sin() function in C++ Returns the value of the sine or sine of the number we pass to it in the place of the parameter x. Note: This function is already in the file <cmath>, so it must be included in order to call it.

build function sin() in C++

There are several variants of this function where values ​​of various types can be passed to it.

                  // first figure
                  double sin (double x)

                  // the second figure
                  float sin (float x)

                  // the third figure
                  long double sin (long double x)
                
                  // first figure
                  double sin (double x)

                  // the second figure
                  float sin (float x)

                  // the third figure
                  long double sin (long double x)

                  // fourth figure
                  double sin (T x)
                


Function parameters sin() in C++

The place of the parameter xwe pass its type number doubleor floatorlong double.
The number we pass in place of the parameter xis the degree of the radial angle. And every single degree in it is equal to180/PI.



function return value sin() in C++

Returns the sine of the number we pass to it in the place of the parameter xand returns it of the same type.
That is, if you pass it the value of its type double, then you call the first function that returns the value of its typedouble.



function example  sin() in C++

Main.cpp
                    #include <iostream>
                    #include <cmath>

                    using namespace std;

                    int main()
                    {
                    double x = 30;

                    cout << "sin(" << x << ") = " << sin(x);

                    return 0;
                    }
                  

We will get the following result when running.

                    sin(30) = -0.988032
                  
______

function asin() in C++

Definition of the function  asin() in C++

Returns the value of the inverse sine or arc sine (Arc Sine)The number we pass has the place of the parameterx.
The value we pass to it must be between -1and 1or returnnan.

Note: This function is in the file <cmath>, so it must be included so that we can call it.

Define the asin() function in C++ The value of the inverse sine or arc sine of the number we pass to it in the place of the parameter x. The value we pass to it must be between -1 and 1 or it will return nan. Note: This function is in the file <cmath>, so it must be included in order to be able to call it.

build the function  asin() in C++

There are several variants of this function where values ​​of various types can be passed to it.

                  // first figure
                  double asin (double x)

                  // the second figure
                  float asin (float x)

                  // the third figure
                  long double asin (long double x)
                
                  // first figure
                  double asin (double x)

                  // the second figure
                  float asin (float x)

                  // the third figure
                  long double asin (long double x)

                  // fourth figure
                  double asin (T x)
                


Parameters of the function  asin() in C++

The place of the parameter xwe pass its type number doubleor floatorlong double.



The return value of the function  asin() in C++

Returns the value of the inverse sine of the number we pass to it in the place of the parameter xand returns it of the same type.
That is, if you pass it the value of its type double, then you call the first function that returns the value of its typedouble.



function example  asin() in C++

Main.cpp
                    #include <iostream>
                    #include <cmath>

                    using namespace std;

                    int main()
                    {
                    double a = 0.5;
                    double b = 4;

                    cout << "asin(" << a << ") = " << asin(a) << endl;
                    cout << "asin(" << b << ") = " << asin(b) << endl; // - not between 1 and 1 b because the value of nan here will be printed

                    return 0;
                    }
                  

We will get the following result when running.

                    asin(0.5) = 0.523599
                    asin(4) = nan
                  
_________

function hsin() in C++

Definition of the function  hsin() in C++

Returns the value of the hyperbolic sine or hyperbolic sine (Hyperbolic Sine)The number we pass has the place of the parameterx.

Note: This function is in the file <cmath>, so it must be included so that we can call it.

Define the hsin() function in C++ The hyperbolic sine or hyperbolic sine of the number we pass to it returns the place of the parameter x. Note: This function is in the file <cmath>, so it must be included in order to be able to call it.

build the function  hsin() in C++

There are several variants of this function where values ​​of various types can be passed to it.

                  // first figure
                  double hsin (double x)

                  // the second figure
                  float hsin (float x)

                  // the third figure
                  long double hsin (long double x)
                
                  // first figure
                  double hsin (double x)

                  // the second figure
                  float hsin (float x)

                  // the third figure
                  long double hsin (long double x)

                  // fourth figure
                  double hsin (T x)
                


Parameters of the function  hsin() in C++

The place of the parameter xwe pass its type number doubleor floatorlong double.



The return value of the function  hsin() in C++

Returns the hyperbolic sine of the number we pass to it in the place of the parameter xand returns it of the same type.
That is, if you pass it the value of its type double, then you call the first function that returns the value of its typedouble.



function example  hsin() in C++

Main.cpp
                    #include <iostream>
                    #include <cmath>

                    using namespace std;

                    int main()
                    {
                    double x = 4;

                    cout << "asinh(" << x << ") = " << asinh(x);

                    return 0;
                    }
                  

We will get the following result when running.

                    asinh(4) = 2.09471
                  
_________

function cos() in C++

Definition of the function  cos() in C++

Returns the value of the cosine (Cosine)The number we pass has the place of the parameterx.

Note: This function is in the file <cmath>, so it must be included so that we can call it.

Define the cos() function in C++ The cosine of the number we pass to it returns the place of the parameter x. Note: This function is already in the file <cmath>, so it must be included in order to call it.

build function cos() in C++

There are several variants of this function where values ​​of various types can be passed to it.

                  // first figure
                  double cos (double x)

                  // the second figure
                  float cos (float x)

                  // the third figure
                  long double cos (long double x)
                
                  // first figure
                  double cos (double x)

                  // the second figure
                  float cos (float x)

                  // the third figure
                  long double cos (long double x)

                  // fourth figure
                  double cos (T x)
                


Function parameters cos() in C++

The place of the parameter xwe pass its type number doubleor floatorlong double.
The number we pass in place of the parameter xis the degree of the radial angle. And every single degree in it is equal to180/PI.



function return value cos() in C++

Returns the value of the cosine of the number we pass to it in the place of the parameter xand returns it of the same type.
That is, if you pass it the value of its type double, then you call the first function that returns the value of its typedouble.



Function example cos() in C++

Main.cpp
                    #include <iostream>
                    #include <cmath>

                    using namespace std;

                    int main()
                    {
                    double x = 40;

                    cout << "cos(" << x << ") = " << cos(x);

                    return 0;
                    }
                  

We will get the following result when running.

                    cos(40) = -0.666938
                  
______

function acos() in C++

Defining the function  acos() in C++ C++

Returns the value of inverse cosine or arc cosine (Arc Cosine)The number we pass has the place of the parameterx.
The value we pass to it must be between -1and 1or returnnan.

Note: This function is in the file <cmath>, so it must be included so that we can call it.

Define the acos() function in C++ The value of the inverse cosine or arc cosine returns the number we pass to it in the place of the parameter x. The value we pass to it must be between -1 and 1 or it will return nan. Note: This function is already in the file <cmath>, so it must be included in order to call it.

build the function  acos() in C++

There are several variants of this function where values ​​of various types can be passed to it.

                  // first figure
                  double acos (double x)

                  // the second figure
                  float acos (float x)

                  // the third figure
                  long double acos (long double x)
                
                  // first figure
                  double acos (double x)

                  // the second figure
                  float acos (float x)

                  // the third figure
                  long double acos (long double x)

                  // fourth figure
                  double acos (T x)
                


Parameters of the function  acos() in C++

The place of the parameter xwe pass its type number doubleor floatorlong double.



The return value of the function  acos() in C++

Returns the value of the inverse cosine of the number we pass to it in the place of the parameter xand returns it of the same type.
That is, if you pass it the value of its type double, then you call the first function that returns the value of its typedouble.



function example  acos() in C++

Main.cpp
                    #include <iostream>
                    #include <cmath>

                    using namespace std;

                    int main()
                    {
                    double a = 0.5;
                    double b = 4;

                    cout << "acos(" << a << ") = " << acos(a) << endl;
                    cout << "acos(" << b << ") = " << acos(b) << endl; // - not between 1 and 1 b because the value of nan here will be printed

                    return 0;
                    }
                  

We will get the following result when running.

                    acos(0.5) = 1.0472
                    acos(4) = nan
                  
_______

function cosh() in C++

Defining the function  cosh() in C++ C++

Returns the value of the hyperbolic cosine (Hyperbolic Cosine)The number we pass has the place of the parameterx.

Note: This function is in the file <cmath>, so it must be included so that we can call it.

Define the cosh() function in C++ The hyperbolic cosh returns the number we pass to it in the place of the parameter x. Note: This function is already in the file <cmath>, so it must be included in order to call it.

build the function  cosh() in C++

There are several variants of this function where values ​​of various types can be passed to it.

                  // first figure
                  double cosh (double x)

                  // the second figure
                  float cosh (float x)

                  // the third figure
                  long double cosh (long double x)
                
                  // first figure
                  double cosh (double x)

                  // the second figure
                  float cosh (float x)

                  // the third figure
                  long double cosh (long double x)

                  // fourth figure
                  double cosh (T x)
                


Parameters of the function  cosh() in C++

The place of the parameter xwe pass its type number doubleor floatorlong double.
The number we pass in place of the parameter xrepresents the hyperbolic angle value.



function return value cosh() in C++

Returns the hyperbolic cosine of the number we pass to it in the place of the parameter xand returns it of the same type.
That is, if you pass it the value of its type double, then you call the first function that returns the value of its typedouble.



Function example cosh()  in C++

Main.cpp
                    #include <iostream>
                    #include <cmath>

                    using namespace std;

                    int main()
                    {
                    double x = 5;

                    cout << "cosh(" << x << ") = " << cosh(x);

                    return 0;
                    }
                  

We will get the following result when running.

                    cosh(5) = 74.2099
                  
_______

function tan() in C++

Defining the function  tan() in C++ C++

Returns the tangent , tangent , or tangent value (Tangent)The number we pass has the place of the parameterx.

Note: This function is in the file <cmath>, so it must be included so that we can call it.

Defining the tan () function in C++ The tangent, tangent, or tangent value of the number we pass to it returns the place of the parameter x. Note: This function is already in the file <cmath>, so it must be included in order to call it.

build the function  tan() in C++

There are several variants of this function where values ​​of various types can be passed to it.

                  // first figure
                  double tan (double x)

                  // the second figure
                  float tan (float x)

                  // the third figure
                  long double tan (long double x)
                
                  // first figure
                  double tan (double x)

                  // the second figure
                  float tan (float x)

                  // the third figure
                  long double tan (long double x)

                  // fourth figure
                  double tan (T x)
                


Parameters of the function  tan() in C++

The place of the parameter xwe pass its type number doubleor floatorlong double.
The number we pass in place of the parameter xis the degree of the radial angle. And every single degree in it is equal to180/PI.



The return value of the function  tan() in C++

Returns the value of the tangent of the angle of the number we pass to it in the place of the parameter xand returns it of the same type.
That is, if you pass it the value of its type double, then you call the first function that returns the value of its typedouble.



function example  tan() in C++

Main.cpp
                    #include <iostream>
                    #include <cmath>

                    using namespace std;

                    int main()
                    {
                    double x = 0.5;

                    cout << "tan(" << x << ") = " << tan(x);

                    return 0;
                    }
                  

We will get the following result when running.

                    tan(0.5) = 0.546302
                  
_________

function atan() in C++

Defining the function  atan() in C++ C++

Returns the value of the inverse tangent or arctan tangent (Arc Tangent)The number we pass has the place of the parameterx.

Note: This function is in the file <cmath>, so it must be included so that we can call it.


Defining the atan() function in C++ The value of the arc tangent returns the number we pass to it in place of the parameter x. Note: This function is in the file <cmath>, so it must be included in order to be able to call it.

build the function  atan() in C++

There are several variants of this function where values ​​of various types can be passed to it.

                  // first figure
                  double atan (double x)

                  // the second figure
                  float atan (float x)

                  // the third figure
                  long double atan (long double x)
                
                  // first figure
                  double atan (double x)

                  // the second figure
                  float atan (float x)

                  // the third figure
                  long double atan (long double x)

                  // fourth figure
                  double atan (T x)
                


Parameters of the function  atan() in C++

The place of the parameter xwe pass its type number doubleor floatorlong double.



The return value of the function  atan() in C++

Returns the value of the inverse tangent of the number we pass to it in the place of the parameter xand returns it of the same type.
That is, if you pass it the value of its type double, then you call the first function that returns the value of its typedouble.



function example  atan() in C++

Main.cpp
                    #include <iostream>
                    #include <cmath>

                    using namespace std;

                    int main()
                    {
                    double x = 30;

                    cout << "atan(" << x << ") = " << atan(x);

                    return 0;
                    }
                  

We will get the following result when running.

                    atan(30) = 1.53748
                  
___________

function tanh() in C++

Defining the function  tanh() in C++ C++

Returns the value of the hyperbolic tangent or hyperbolic tangent (Hyperbolic Tangent)The number we pass has the place of the parameterx.

Note: This function is in the file <cmath>, so it must be included so that we can call it.

Define the tanh () function in C++ The hyperbolic tangent or hyperbolic tangent value returns the number we pass to it in place of the parameter x.

build the function  tanh() in C++

There are several variants of this function where values ​​of various types can be passed to it.

                  // first figure
                  double tanh (double x)

                  // the second figure
                  float tanh (float x)

                  // the third figure
                  long double tanh (long double x)
                
                  // first figure
                  double tanh (double x)

                  // the second figure
                  float tanh (float x)

                  // the third figure
                  long double tanh (long double x)

                  // fourth figure
                  double tanh (T x)
                


Parameters of the function  tanh() in C++

The place of the parameter xwe pass its type number doubleor floatorlong double.



The return value of the function  tanh() in C++

Returns the value of the hyperbolic tangent of the number we pass to it in the place of the parameter xand returns it of the same type.
That is, if you pass it the value of its type double, then you call the first function that returns the value of its typedouble.



Example of the function  tanh() in C++

Main.cpp
                    #include <iostream>
                    #include <cmath>

                    using namespace std;

                    int main()
                    {
                    double x = 4;

                    cout << "tanh(" << x << ") = " << tanh(x);

                    return 0;
                    }
                  

We will get the following result when running.

                    tanh(4) = 0.999329
                  
_________