1#include <iostream>
2#include <cstdlib>
3using namespace std;
4
5int main()
6{
7 int x = -5;
8 long y = -2371041;
9
10 int a = abs(x);
11 long b = abs(y);
12
13 cout << "abs(" << x << ") = |" << x << "| = " << a << endl;
14 cout << "abs(" << y << ") = |" << y << "| = " << b << endl;
15}
16
17/* output
18abs(-5) = |-5| = 5
19abs(-2371041) = |-2371041| = 2371041*/
1#include <iostream>
2#include <cstdlib>
3using namespace std;
4
5int main() {
6
7 // get absolute value of -5
8 cout << abs(-5);
9
10 return 0;
11}
12
13// Output: 5
1#include <iostream>
2#include <cstdlib>
3using namespace std;
4
5int main() {
6 int x = -5;
7 long y = -2371041;
8
9 int a = abs(x);
10 long b = abs(y);
11
12 cout << "abs(" << x << ") = |" << x << "| = " << a << endl;
13 cout << "abs(" << y << ") = |" << y << "| = " << b << endl;
14}
15
16returns
17abs(-5) = |-5| = 5
18abs(-2371041) = |-2371041| = 2371041
1#include <iostream>
2#include <cstdlib>
3using namespace std;
4
5int main() {
6 int x = -5;
7 long y = -2371041;
8
9 int a = abs(x);
10 long b = abs(y);
11
12 cout << "abs(" << x << ") = |" << x << "| = " << a << endl;
13 cout << "abs(" << y << ") = |" << y << "| = " << b << endl;
14}