Showing posts with label llabs function. Show all posts
Showing posts with label llabs function. Show all posts

Aug 17, 2020

abs(); , labs(); and llabs(); functions in library of C++ | C++ Language | Coding Winds

abs(); , labs(); and llabs(); Function in C++

Hello people, today we are going to read about the abs(); , labs(); and llabs(); function in C++. For using these functions we need to include <cstdlib> library. This function returns the absolute value of the integer value it takes as an argument.

It is very helpful when we need to print a mathematical mod value of some number(|x|).

1.    abs() function :

In this function the input is of the data-type int, long int, or long long int and it returns the absolute value of the same data type as it was of input. A C++ program below given shows the implementation of this function.

INPUT :

          -4

OUTPUT :

          4

1.    labs() function :

In this function the input is of the long int data-type and it returns the absolute value of the long int data type. A C++ program below given shows the implementation of this function.

INPUT :

          -40620

OUTPUT :

          40620

1.    llabs() Function :

In this function the input is of the long long int data-type and it returns the absolute value of the long long int data type. A C++ program below given shows the implementation of this function.

INPUT :

          -40620

OUTPUT :

          40620