Home
menubar
rss_feed

Previous Reference C++ Reference <cstdlib> Next Reference




C++ Reference: abs()





abs()


Declaration

int abs(int);

Description

Returns the absolute value of an int.

Related Functions *

long labs(long lNumber);

* Note: Since C does not allow function overloading, these other versions of this function exist.

Example

#include <iostream>
#include <cstdlib>

int main() {
    using namespace std;

    cout << abs(17) << endl;
    cout << abs(-17) << endl;

    return 0;
}


Output:








Previous Reference C++ Reference <cstdlib> Next Reference




Home | Reference | Play Games! | Blog | Forum | Site Map | Contact Us


shadow bottom image