Math

Math

Math

C++ includes many math functions in its standard library. Here are some examples:

  1. Basic math operations:

We have learn how to perform basic mathematic functions using arithmetic operators (for example +,-,*,/ etc.)

  1. Advanced math functions:

Square root: use the sqrt() function from the <cmath> library, for example:

				
					#include<cmath>

double result = sqrt(25); // result = 5.0
				
			

Power: use the pow() function from the <cmath> library, for example:

Trigonometric functions: use functions such as sin(), cos(),     and tan() from the <cmath> library, for example:

				
					#include<cmath>

double result = pow(2, 3); // result = 8.0
				
			
  1. Constants:

Pi: use the M_PI constant from the <cmath> library, for example:

				
					#include<cmath>

double result = M_PI; // result = 3.14159
				
			

Infinity: use the INFINITY constant from the <cmath> library, for example:

				
					#include<cmath>

double result = INFINITY; // result = infinity
				
			
Join To Get Our Newsletter
Spread the love