How to use abs() function to get the absolute value of N in C

1 Answer

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

int main(int argc, char **argv)
{
	printf("%d\n", abs(-20)); 
	printf("%d\n", abs(20)); 
	printf("%d\n", abs(-3.14)); 
	printf("%d\n", abs(3.14)); 

	return 0;
}

/*
run:

20
20
3
3

*/ 

 



answered Mar 12, 2016 by avibootz
edited Mar 12, 2016 by avibootz
...