Cromo
0
Q:

absolute difference c++

#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*/
7
[Mathematics] |x| = abs(x) [C++ Programming]
7
val1 = abs(22); 
val2 = abs(-43); 
  
cout << "abs(22) = " << val1 << "\n"; 
cout << "abs(-43) = " << val2 << "\n";
0

New to Communities?

Join the community