#### UMBC CMSC 201, Computer Science I, Fall 1995 Sections 0101, 0102, 0103 and Honors

People have been asking pretty much the same questions. So, let's just summarize the answers.

• The normal form for zero is 0/1.

• Make sure that your LessThanFraction function works when you compare 7/8 versus 3/4 and 5/8 versus 3/4. If you have a whole bunch of if statements for this function, chances are that you don't have it right.

• If you want to submit a new version of your project, just resubmit it. We will grade the most recent submission.

• If you want to have extra functions (e.g., the GCD function), you should put the prototypes for these functions at the top of your proj3.c file. Since these functions are not used by functions in other files, they do not belong in proj3.h.

• The return value of the functions AddFraction, etc. should be in normal form. That is the numerator and the denominator should not have any common divisors greater than 1, and the denominator should not be negative.

• If you are having trouble with MakeFraction returning values that are not in normal form, check your ReduceFraction function. Several people complained about having a negative denominator, but it turns out that they tried to take the GCD of a positive and a negative number. The GCD algorithm from the book is for positive numbers only.

• Think about what you want to do if someone calls your functions with unreduced fractions (e.g., 2/4). You basically have 3 options.
1. Your function could crash. That is, your function checks to see if the fractions are reduced. If they are not then you use the Error function to halt the entire program and return control to the operating system.
2. Your function could guarantee that the correct answer is produced, even if the function is called with unreduced fractions.
3. Your function could be unpredictable and sometimes quietly produce the wrong answer.
Think about these cases. Which one do you want to implement? All three are "allowed" because it is not part of the "contract" that your functions should handle fractions not in normal form. Clearly, the last option is nastiest. The first option is not bad, perhaps a bit unfriendly. The second option is "nice" but this means your functions have some undocumented features. This could lead to incompatibility problems in the future. Finally, what does your EqualFraction function do?

By the way, if you send me email to ask me a specific question, do not send the email anonymously. I won't be able to reply to you. You should also include your program (use read in PINE, no MIME attachments please) so I can see what you are doing. I will try to do my best, but it is very difficult to guess who you are and what your problem is if you don't tell me anything!