Use C abs function to get the absolute value

Syntax

C abs function has the following syntax.

int abs(int num);

C abs function is from header file stdlib.h.

Description

C abs function returns the absolute value of num.

Example

C abs function gets the absolute value.


#include <stdlib.h>
#include <stdio.h>
/*w w w.ja  v a 2  s.co m*/
int main(void){

  printf("%d",abs(-1));

}

The code above generates the following result.





















Home »
  C Language »
    Function Reference »




assert.h
ctype.h
math.h
setjmp.h
signal.h
stdio.h
stdlib.h
string.h
time.h
wctype.h