abs()
net137228473814 total contributions
Published Jun 18, 2021Updated Jul 20, 2023
Contribute to Docs
The abs()
function returns the absolute value of the argument.
Syntax
abs(n)
Example 1
Use abs()
to return the absolute value of -6.5
:
#include <iostream>#include <cmath>int main() {std::cout << std::abs(-6.5) << "\n";// Output: 6.5}
Codebyte Example
The following example is runnable and outputs the absolute value of -5.1
:
All contributors
- net137228473814 total contributions
- Christine_Yang271 total contributions
- garanews222 total contributions
- christian.dinh2476 total contributions
- Anonymous contributorAnonymous contributor3071 total contributions
- net1372284738
- Christine_Yang
- garanews
- christian.dinh
- Anonymous contributor
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.