Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

c++

How to use llabs() in C++

Behzad Ahmad

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;
}

RELATED TAGS

c++

CONTRIBUTOR

Behzad Ahmad
Copyright ©2022 Educative, Inc. All rights reserved
RELATED COURSES

View all Courses

Keep Exploring