Advertisement
thenewboston

C Programming Tutorial - 36 - Rounding Numbers

Aug 22nd, 2014
394
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.43 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <ctype.h>
  4. #include <string.h>
  5. #include <math.h>
  6.  
  7. int main()
  8. {
  9.     float bacon1 = 9.6245;
  10.     float bacon2 = 3.3;
  11.  
  12.     //floor rounds down
  13.     printf("bacon1 is %.1f \n", floor(bacon1) );
  14.     printf("bacon2 is %.1f \n", floor(bacon2) );
  15.  
  16.     //ceil rounds down
  17.     printf("bacon1 is %.1f \n", ceil(bacon1) );
  18.     printf("bacon2 is %.1f \n", ceil(bacon2) );
  19.  
  20.     return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement