Check out example codes for "how to find absolute value in c++". It will help you in understanding the concepts better.

Code Example 1

#include <iostream>
#include <cstdlib>
using namespace std;

int main()
{
	int x = -5;
	long y = -2371041;

	int a = abs(x);
	long b = abs(y);

	cout << "abs(" << x << ") = |" << x << "| = " << a << endl;
	cout << "abs(" << y << ") = |" << y << "| = " << b << endl;
}

/* output
abs(-5) = |-5| = 5
abs(-2371041) = |-2371041| = 2371041*/

Code Example 2

[Mathematics] |x| = abs(x) [C++ Programming]

Learn ReactJs, React Native from akashmittal.com