C library functions - labs ()
C standard library - <stdlib.h>
description
C library functionslong int labs (long int x) Returns the absolute value of x.
statement
Here is the () function declaration labs.
long int labs(long int x)
parameter
- x - the complete value.
return value
This function returns the absolute value of x.
Examples
The following example demonstrates labs () function is used.
#include <stdio.h> #include <stdlib.h> int main () { long int a,b; a = labs(65987L); printf("a 的值 = %ld\n", a); b = labs(-1005090L); printf("b 的值 = %ld\n", b); return(0); }
Let's compile and run the above program, which will result in the following:
a 的值 = 65987 b 的值 = 1005090