C++ Program To Find Absolute Value Of Number

C++ Program To Find Absolute Value Of Number

//Write C++ program to find absolute value of number

#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n , absolute;

    cout << "Enter the value :--> ";
    cin >> n ;

    absolute = abs(n);       //abs function in stdlib header file

    cout << "The absolute value of the number is :--> " << absolute ;

    return 0;
}

Output:

Enter the value :–> -11


The absolute value of the number is :–> 11


<< Previous | Next >>