lolamontes69

K+R Exercise1_15

Sep 5th, 2014
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.42 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. #define UPPER 300
  4. #define LOWER 0
  5. #define STEP  20
  6.  
  7. float celstofahr(int cels);   // Returns a float value.
  8.  
  9. int main()
  10. {
  11.     int celsius;
  12.  
  13.     printf("%3s%6s\n", "Cels", "Fahr");
  14.     for(celsius=UPPER;celsius>=LOWER;celsius=celsius-STEP)
  15.         printf("%3d %6.1f\n", celsius, celstofahr(celsius));
  16.     return(0);
  17. }
  18.  
  19. float celstofahr(int cels)
  20. {
  21.     return((((cels*9.0)/5.0))+32.0);
  22. }
Advertisement
Add Comment
Please, Sign In to add comment