samir82show

c_ch01_ex02.c

Sep 21st, 2014
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. /*Exercise 1-2. Experiment to find out what happens when prints's argument string contains \c, where c is some character not listed above.*/
  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("%5s \b %6s\n", f, c);
  16. while (fahr <= upper) {
  17. celsius = (5.0/9.0) * (fahr-32.0);
  18. printf("%5.0f %6.1f\n", fahr, celsius);
  19. fahr = fahr + step;
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment