Math Functions
Include <cmath> for sqrt, pow, abs, round, ceil, floor and more. std::max and std::min live in <algorithm>.
Example
cout << sqrt(81) << endl;
cout << pow(2, 10) << endl;
cout << round(4.6) << " " << floor(4.9) << " " << ceil(4.1) << endl;
cout << max(3, 9) << " " << min(3, 9) << endl;
cout << abs(-7) << endl;Result
9 1024 5 4 5 9 3 7
Exercise
Raise 2 to the power 10.
(2, 10)Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.