C++ Program to find the absolute value of long and float numbers


In this program, You will learn how to find the absolute value of long and float numbers in C++.


Find absolute in C++

long x=abs(-390090);

Example: How to find the absolute value of long and float numbers in C++.

#include<iostream>
#include<math.h>
using namespace std;

int main() {

   long x = -200039;
   float y = -239.55f;

   x = abs(x);
   y = abs(y);
   cout << "Long abolute value is :" << x << endl;
   cout << "Float absolute value is :" << y;

   return 0;
}

Output:

Long abolute value is :200039
Float absolute value is :239.55