Answers for "abs val of a number in c++"

C++
0

abs val of a number in 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;
}
Posted by: Guest on July-09-2021

Browse Popular Code Answers by Language