How to use llabs() in C++

The llabs() function in C++ returns the absolute value of a long, long int data.

It is similar to the abs() and labs() functions except for the type of parameters.

Standard library

#include<cstdlib>

Syntax of llabs() function


long long int llabs(long long int n)

Parameters

  • n - represents the value whose absolute value is to be found

Return value

It returns the absolute value.

Example

Input:
n = -1234567890987654321

Function call:
llabs(n);

Output:
1234567890987654321

Code

#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
long long x,y;
x = -1234567890987654321;
y = 1234567890987654321;
cout << "llabs(" << x << ") = " << llabs(x) << endl;
cout << "llabs(" << y << ") = " << llabs(y) << endl;
return 0;
}

Free Resources

HowDev By Educative. Copyright ©2025 Educative, Inc. All rights reserved