abs - C stdlib.h

C examples for stdlib.h:abs

Type

function

From


<cstdlib>
<stdlib.h>

Description

Returns the absolute value of parameter n (|n|).

Prototype

long long int abs (long long int n);
          int abs (int n);
     long int abs (long int n);

Parameters

Parameter Description
n Integral value.

Return Value

The absolute value of n.

Demo Code


#include <stdio.h>
#include <stdlib.h>

int main ()//w w w  .  j a va2 s .co m
{

  printf ("%d\n", abs(23));

  printf ("%d\n",abs(-11));


  printf ("%d\n", abs(0));

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

  return 0;
}

Related Tutorials