labs - C stdlib.h

C examples for stdlib.h:labs

Type

function

From


<cstdlib>
<stdlib.h>

Description

Returns the absolute value of parameter n (|n| ). This is the long int version of abs.

Prototype

long int labs (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  v  a2s  .  c o  m*/
{
  long int n,m;

  n=labs(65537L);

  m=labs(-100000L);

  printf ("n=%ld\n",n);

  printf ("m=%ld\n",m);

  return 0;
}

Related Tutorials