C Programming Homework #2: Fahrenheit to Celsius

Due: Monday, February 1, 2016

This assignment gets you programming!

Over this week and the next we'll be looking at Lesson #5, Lesson #6, Lesson #7, and Lesson #8. Those lessons go into more detail than we need for this assignment, but all the material in them will be covered soon enough.

  1. Write a program that makes a conversion table from degrees Fahrenheit to degrees Celsius. Your program should prompt the user for three inputs (all double precision floating point numbers): a start temperature, an end temperature, and a temperature step. These temperatures are all assumed to be in degrees Fahrenheit. The program should then print an appropriate table.

    Here is a sample run of the program:

      $ f2c
      Start: 50
      End  : 80
      Step : 10
    
      degrees F   degrees C
      ---------   ---------
          50.00       10.00
          60.00       15.56
          70.00       21.11
          80.00       26.67
      $
    

    Notice that the degrees F for each row is advanced by an amount given by the temperature step. The precise format of the table is up to you but be sure it "looks good." It should have decimal points aligned in both columns. I recommend using two decimal places (but you can use some other number if you want). Be sure to allow negative temperatures and account for a negative sign when planning the output.

    The conversion formula is given by C = (5/9)(F - 32). However, be sure to use floating point constants; specifically 5/9 as written will be computed as zero by the program (why?) and you don't want that.

  2. What does your program do if the interval between the start and end temperaturs is not evenly divisable by the temperature step size? Does the behavior seem reasonable to you?

Submit your program to Moodle (the .c file). Be sure it includes a comment block at the top that includes your name, the name of the file, the date, and a brief description of what the program does..


Last Revised: 2016-01-25
© Copyright 2016 by Peter C. Chapin <PChapin@vtc.vsc.edu>