Table of Content

Abs(x) >> Absolute Value >> Math.h Function



Abs >> Math.h Function >>
Syntax 1 [Return Double] :

double abs(complex x);

Syntax 2 [Return Integer] :

int abs(int x);
  1. abs is not a function , it is macro
  2. This Macro gives the absolute value of an integer.
  3. If abs is called when STDLIB.H has been included, it is treated as a macro that expands to inline code.
  4. If you want to use the abs function instead of the macro, include #undef abs in your program, after the #include <STDLIB.H>. 

Live Example :

#include<stdio.h>
#include< math.h>

int main(void)
{
int number = -1234;
printf("number: %d absolute value: %dn", number, abs(number));
return 0;
}

Output :

number : -1234  absolute value : 1234