This is an old revision of this page, as edited by PokestarFan (discuss | contribs) at 13:53, 28 May 2017. It may differ significantly from the current revision. |
Syntax |
#include <cstdlib>
int abs( int num );
|
The abs() function returns the absolute value of num. For 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;