Labs () function in C

Labs () function in C

Function long int labs (long int x) returns the absolute value of x.

Declare labs () function in C

Below is the declaration for labs () in C:

 long int labs ( long int x ) 

Parameters

x: an integer value.

Returns the value

This function returns the absolute value of x.

For example

The following C program illustrates the usage of labs () in C:

 #include #include int main () { long int a , b ; a = labs ( 65987L ); printf ( "Gia tri cua a = %ldn" , a ); b = labs (- 1005090L ); printf ( "Gia tri cua b = %ldn" , b ); return ( 0 ); } 

Compiling and running the above C program will result:

Labs () function in C Picture 1

According to Tutorialspoint

Previous lesson: Div () function in C

Next lesson: The function ldiv () in C

4 ★ | 1 Vote

May be interested

  • MIN function in SQL ServerMIN function in SQL Server
    the article will explore and show you how to use the min function in sql server to find the smallest value in a set.
  • MAX function in SQL ServerMAX function in SQL Server
    the article will explore and show you how to use the max function in sql server to find the maximum value in a set.
  • Gmail labs: increase functionality for GmailGmail labs: increase functionality for Gmail
    gmail is the most popular webmail service of google thanks to support for many features such as pop3, imap mail checking, simple and easy-to-use interface.
  • SUM function in SQL ServerSUM function in SQL Server
    the sql server sum function returns the total value of a column, a data set, or an expression.
  • The ord () function in PythonThe ord () function in Python
    the built-in ord () function in python returns an integer representing the unicode code of the specified character.
  • RIGHT function in SQL ServerRIGHT function in SQL Server
    the article will explore and guide you how to use the right function in sql server to extract some characters from the right side of a given string.
  • Int () function in PythonInt () function in Python
    the int () function in python returns an integer object from any number or string.
  • AVG function in SQL ServerAVG function in SQL Server
    the avg function in sql server returns the average value of an expression or average value according to the specified column of the selected row.
  • Hex () function in PythonHex () function in Python
    the hex () function is one of python's built-in functions, used to convert an integer into the corresponding hexadecimal form.
  • ABS function in SQL ServerABS function in SQL Server
    this article will show you in detail how to use the abs () handling function in sql server with specific syntax and examples to better visualize and capture functions.