Math Functions in C++ | Topic 5 | VU Insider

What if you have to perform mathematical tasks on numbers? C++ provides this facility to programmer. There are two math functions (min & max) that can be used without including any library into the header.
Functions: min(x, y) & max(x, y)

Other functions can be used with adding library in the header.

min (x, y) function

min(x, y) is used to find the lowest value between x and y.

cout << min(3, 5); // This will print 3 as it is the lowest valuecode-box

max (x, y) function

max(x,y) - used to find the highest value between x and y.

cout << max(3, 5); // This will print 5 as it is the highest valuecode-box

Other Math Functions

Other math functions that can be allowed by using library.
sqrt(x)Returns square root of x
round(x)Returns round value of x
log(x)Returns logarithm of x
sin(x)Returns sin of x
cbrt(x)Returns cube root of x

Post a Comment

Previous Post Next Post