samir82show

c_ch01_ex04.c

Sep 22nd, 2014
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. /*Exercise 1-4. Write a program to print the corresponding Celsius to Fahrenheit table*/
  2.  
  3. #include <stdio.h>
  4. /* print Fahrenheit-Celsius table
  5. for fahr = 0, 20, ..., 300; floating-point version */
  6. main()
  7. {
  8. float fahr, celsius;
  9. char *f = "Faher", *c = "Celsi";
  10. float lower, upper, step;
  11. lower = 0; /* lower limit of temperatuire scale */
  12. upper = 300; /* upper limit */
  13. step = 20; /* step size */
  14. fahr = lower;
  15. printf("%6s %5s\n", c, f);
  16. while (celsius <= upper) {
  17. fahr = ((celsius * 9.0)/5.0) + 32.0;
  18. printf("%6.1f %5.0f\n", celsius, fahr);
  19. celsius = celsius + step;
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment