Monday, 24 June 2013

abs in c math.h



abs c - math.h


abs is not a function but is a macro and is used for calculating absolute value of a number.

C programming code for abs
#include <stdio.h>
#include <math.h>

int main()
{
  int n, res;

  printf("Enter an integer to calculate it's absolute value\n");
  scanf("%d", &n);

  result = abs(n);

  printf("Absolute value of %d = %d\n", n, res);

  return 0;
}




12aj1f0001.blogspot.com





No comments: