Mega Code Archive

 
Categories / C / Code Snippets
 

Return absolute value of integer parameter how to use abs

#include <stdio.h> #include <math.h> int main () { int j, k; j = abs( 3 ); k = abs( -1 ); printf (" j = %d \n", j); printf (" k = %d\n", k); return 0; }