Home » C Programs » Absolute Value Function in C

# Absolute Value Function in C

The abs () function returns the absolute value of the given integers and is defined in the stdlib. h header file. So, in order to return the absolute value of a given number, the C program must include the stdlib.h header file. Only positive numbers are returned by the abs() function.

## Function in C

The abs function returns an integer’s absolute value in the C programming language. The absolute value of an integer is returned by the abs( ) function in C. Every number has a positive absolute value.

In C, you can only use integer values. An example of asset-based security is a collateralized debt obligation. It’s similar to a loan or bond in that it’s backed by a portfolio of debt instruments, such as bank loans, mortgages, credit card receivables, airplane leases, smaller bonds, and occasionally even other ABSs or CDOs.

## Uses of ABS Function in C

The abs() method is used to return a number’s absolute value. Only one input is required for abs(): an integer whose absolute value is to be returned. An integer, a floating-point number, or a complex number can be used as the parameter.

## Standard Library Function in C and Its Uses

String handling, mathematical computations, input/output processing, memory management, and a variety of other operating system services are all covered by the C standard library, which includes macros, type definitions, and functions.

h is the header of the c programming language’s general-purpose standard library, which includes functions for memory allocation, process control, conversions, and more.

It is compatible with C++ and is referred to as c stdlib in that language. “Stdlib” is an acronym for “standard library.” Stdlib is important concept in programming languge to execute the abs function in c.

## Absolute Value Function in C

``````//absolute value function in c
#include <stdio.h>
#include <stdlib.h>
int main()
{
int a = abs(100);
int b = abs(-500);
printf("Absolute or abs number of a = %d\n",a);
printf("Absolute or abs number of b = %d",b);
return 0;
}``````

Output:

Absolute or abs number of a = 100

Absolute or abs number of b = 500