Joel
0
Q:

c round function

float f = 0.5;

round(f);
2
/* Program for rounding floating point numbers */
# include<stdio.h> 
  
int roundNo(float num) 
{ 
    return num < 0 ? num - 0.5 : num + 0.5; 
} 
  
int main() 
{ 
    printf("%d", roundNo(-1.777)); 
    getchar(); 
    return 0; 
} 
1
   #include <math.h>

   double round(double x);
   float roundf(float x);
   long double roundl(long double x);
0

New to Communities?

Join the community