0% found this document useful (0 votes)
9 views2 pages

Other Math Functions: C++ Maths

The document contains three C++ programs, each demonstrating a different math function: finding the highest of two numbers, finding the lowest of two numbers, and calculating the square root, roundoff, and log of a number. It also includes a table listing additional common math functions available in the C++ cmath library.

Uploaded by

Ashfaq Khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views2 pages

Other Math Functions: C++ Maths

The document contains three C++ programs, each demonstrating a different math function: finding the highest of two numbers, finding the lowest of two numbers, and calculating the square root, roundoff, and log of a number. It also includes a table listing additional common math functions available in the C++ cmath library.

Uploaded by

Ashfaq Khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

C++ Maths

// Write a program in C++ to find the highest of 2 numbers

#include <iostream>

#include <cmath>

int main()

cout << max(5, 10);

return 0;

// Write a program in C++ to find the lowest of 2 numbers

#include <iostream>

#include <cmath>

int main()

cout << min(5, 10);

return 0;

// Write a program in C++ to find the squareroot, round off, log of a numbers

#include <iostream>

#include <cmath>

int main() {

cout << sqrt(64) << "\n";

cout << round(2.6) << "\n";

cout << log(2) << "\n";

return 0;

Other Math Functions


A list of other popular Math functions (from the <cmath> library) can be found
in the table below:

Function Description
abs(x) Returns the absolute value of x
acos(x) Returns the arccosine of x
asin(x) Returns the arcsine of x
atan(x) Returns the arctangent of x
cbrt(x) Returns the cube root of x
ceil(x) Returns the value of x rounded up to its nearest integer
cos(x) Returns the cosine of x
cosh(x) Returns the hyperbolic cosine of x
exp(x) Returns the value of Ex
expm1(x) Returns ex -1
fabs(x) Returns the absolute value of a floating x
fdim(x, y) Returns the positive difference between x and y
floor(x) Returns the value of x rounded down to its nearest
hypot(x, y) Returns sqrt(x2 +y2) without intermediate overflow or
fma(x, y, z) Returns x*y+z without losing precision
fmax(x, y) Returns the highest value of a floating x and y
fmin(x, y) Returns the lowest value of a floating x and y
fmod(x, y) Returns the floating point remainder of x/y
pow(x, y) Returns the value of x to the power of y
sin(x) Returns the sine of x (x is in radians)
sinh(x) Returns the hyperbolic sine of a double value
tan(x) Returns the tangent of an angle
tanh(x) Returns the hyperbolic tangent of a double value

You might also like