C labs() function
C labs() function - long integer absolute value
Syntax labs() function
long int labs(long int x)
The labs() function is used to compute the absolute value of the long integer operand x.
Parameters labs() function
Name | Description | Required /Optional |
---|---|---|
x | This is the integral value. | Required |
Return value from labs()
- Returns the absolute value of n.
Example: labs() function
The following example shows the usage of labs() function.
#include <stdlib.h>
#include <stdio.h>
int main(void)
{
long x, y;
x = -84532L;
y = labs(x);
printf("The absolute value of %ld is %ld\n", x, y);
x = 84532L;
y = labs(x);
printf("\nThe absolute value of %ld is %ld\n", x, y);
}
Output:
The absolute value of -84532 is 84532 The absolute value of 84532 is 84532
C Programming Code Editor:
Previous C Programming: C div()
Next C Programming: C ldiv()
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join