C Standard Library

C <stdlib.h> - llabs() Function



The C <stdlib.h> llabs() function returns the absolute value (positive value) of the specified integral value. For example - absolute value of integral value x will be |x|.

Syntax

long long int llabs (long long int x);

Parameters

x Specify an integral value whose absolute value need to be determined.

Return Value

Returns the absolute value (positive value) of integral argument.

Example:

The example below shows the usage of <stdlib.h> llabs() function.

#include <stdio.h>
#include <stdlib.h>
 
int main (){
  printf("llabs(10) = %lld\n", llabs(10));
  printf("llabs(-10) = %lld\n", llabs(-10));
  printf("llabs(50) = %lld\n", llabs(-50));
  printf("llabs(-50) = %lld\n", llabs(50));  
  return 0;
}

The output of the above code will be:

llabs(10) = 10
llabs(-10) = 10
llabs(50) = 50
llabs(-50) = 50

❮ C <stdlib.h> Library