#include <cmath>
abs(number);
Ex: abs(-10) = |-10| = 10
//Syntax
abs(int num);
int a =4;
int b =5;
int ans = abs(a-b); //ALWAYS RETURN POSITIVE NUMBER.
/* abs example */
#include <stdio.h> /* printf */
#include <stdlib.h> /* abs */
int main ()
{
int n,m;
n=abs(23);
m=abs(-11);
printf ("n=%d
",n);
printf ("m=%d
",m);
return 0;
}
//abs() returns the absolute value of an integer number.
double a {-5000};
std::cout << "Result : " << std::abs(a) << std::endl;
#include <iostream>
#include <cstdlib>
#include <climits>
int main()
{
std::cout << std::showpos
<< "abs(+3) = " << std::abs(3) << '
'
<< "abs(-3) = " << std::abs(-3) << '
';
}