How to use llround() function to round nearest long long integer value in C

1 Answer

0 votes
#include <stdio.h>     
#include <math.h> 
 
int main(int argc, char **argv)
{   
    printf("llround(3.3) = %lld\n", llround(3.3));
    printf("llround(3.5) = %lld\n", llround(3.5));
    printf("llround(4.5) = %lld\n", llround(4.5));    
	printf("llround(4.6) = %lld\n", llround(4.6));
    printf("llround(-3.3) = %lld\n", llround(-3.3));
    printf("llround(-3.5) = %lld\n", llround(-3.5));
    printf("llround(-4.5) = %lld\n", llround(-4.5));    
	printf("llround(-4.6) = %lld\n", llround(-4.6));
  
    return 0;
}
 
 
/*
run:
   
llround(3.3) = 3
llround(3.5) = 4
llround(4.5) = 5
llround(4.6) = 5
llround(-3.3) = -3
llround(-3.5) = -4
llround(-4.5) = -5
llround(-4.6) = -5

*/

 



answered Mar 25, 2016 by avibootz
...