Google News
logo
CPP - Interview Questions
How to find absolute value in C++?
To find the absolute value in c++, we can use abs() function. The abs() function in C++ returns the absolute value of an integer number.
#include <iostream>
#include <cstdlib>
using namespace std;
 
int main()
{
        int a=5.42;
        int x = abs(a);
        cout << x;
            return 0;
}

Output : 5

Advertisement