abs()

Prototype: int abs(int aNum);
Header File: stdlib.h (C) or cstdlib (C++)
Explanation: The abs function returns the absolute value of a number (makes it positive) as an integer.



Example:
//Program asks for user input of an integer
//It will convert it to positive if it was negative
#include <cstdlib>
#include <iostream>

using namespace std;

int main()
{
  int aNum;
  cout<<"Enter a positive or negative integer";
  cin>>aNum;
  cout<<abs(aNum);
}
Other Functions