CS 2073, Fall 2005
 Program 3
 Equations of a Line
    Week 3: Sep 7-9
 Due (on time): 2005-09-19  23:59:59
 Due (late):        2005-09-21  23:59:59

Program 3 must be emailed to: nrwagner@cs.utsa.edu
following directions for: running and submitting a C program, with deadlines:
  • 2005-09-19  23:59:59 (that's Monday, 19 September 2005, 11:59:59 pm) for full credit.
  • 2005-09-21  23:59:59 (that's Wednesday, 21 September 2005, 11:59:59 pm) for 75% credit.

Special Note: Initial deadline has been pushed off until Monday, 19 Sept. 2005, 11:59:59 pm.


Introduction: Write a C program to display the equation of the straight line through two points on the graph of an equation. The points are obtained by reading values of the x coordinates of the two points. The corresponding y coordinates are obtained from the function.
Details about what to do:
  1. Each successive pair of input numbers will represent the x coordinates x1, and x2 of two points on the graph of a function. The function used must be f(x) = x2-3x-2. You must implement the function f as a C function in the form:

  2. The program should first print the coordinates of the two points in exactly the form:

    Next (on a separate line) print out the equation of the line through the two points. The equation should be in the general form:

    where m is the slope and b is the Y-intercept, both given with two decimal places. For full credit the equation should appear as you might expect to see it in a calculus book. (See Item 6 below.)

  3. Keep reading pairs of numbers and printing out equations of lines until the two numbers read in are both 0.0. Then the program should terminate gracefully.

  4. Your program should correctly handle any reasonable input. In particular it must deal with each of the following cases:

  5. Your program should be well-documented and formatted. You should use in dentation, blank lines, internal comments, meaningful identifiers, annotated identifiers, a consistent style, and header comments as in Assignment 1.

  6. One of the challenging parts of this assignment is to write out the equation of the line in a "nice" form, as you might see it in a calculus book. For full credit, you should conform to the following rules:


Sample input: Here is sample data for your program. For convenience with the use of Visual Studio, use the following file which has these numbers with no line breaks: lines.dat. Then just copy it all into the terminal window.


Sample output: Here is what the output might look like. (Yours does not have to look exactly like this. In particular, this does the extra credit part.)


What you should email: Refer to the submissions directions and to deadlines at the top of this page. The text file that you submit should first have Your Name, the Course Number, and the Program Number. The rest of the file should have the following in it, in the order below, and clearly labeled, including at the beginning the appropriate item letters: a, b, c, etc.

 Contents of email submission for Program 3:

Last Name, First Name; Course Number; Program Number.

  1. C source for your program, quadratic.c. (Or whatever you wish to name it.)
  2. Results of a run or runs of the program, including at least all the 8 sets of data above.


Revision date: 2005-09-05. (Please use ISO 8601, the International Standard.)