Currently At: Programming Reference > C Reference > Standard C Math > abs()

abs()


Syntax:
#include <stdlib.h>
int abs( int num );


Description:
The abs() function returns the absolute value of num.

Example:
int magic_number = 10;
cout << "Enter a guess: ";
cin >> x;
cout << "Your guess was " << abs( magic_number - x ) << " away from the magic number." << endl;


Related Topics:
labs()


Web Standards & Support:

Link to and support eLook.org Powered by LoadedWeb Web Hosting
Valid XHTML 1.0! Valid CSS! eLook.org FireFox Extensions