Due Date:
Friday, April 12, 2002
Points: 100
where "14" and "49" are numbers the user types and "7" is the corresponding GCD. Be sure to check the input for validity, and terminate the program when the user types an end of file character! ( Hint: The classic algorithm for computing the GCD, known as Euclid's Algorithm, goes as follows. Let m and n be variables containing the two numbers. Divide m by n. Save the divisor in m, and save the remainder in n. If n is 0, stop; m contains the GCD. Otherwise, repeat the process, starting with the division of m by n.)
Write a program to find the largest value of epsilon on your computer. Note that the value of epsilon may be different for floats and doubles. Find both values (and the value for long doubles if your compiler supports them). Also, use 1.0 rather than 0.0 to test epsilon because most computers have special hardware instructions for handling zero arithmetic. ( Hint: for gcc(1), a long double is the same as a double.)
The relevant characters, and the C escape sequences to be printed when those characters are encountered, are:
The "anything else" entry means that any non-printing character other than the ones named in the table is to be printed as a sequence of three octal digits preceded by a backslash. When the escape sequence for a newline is printed, the program is to skip to the next line.
Unfortunately, the program as saved in vis.c will not even compile, let alone run. And the programmer thoughtlessly left off all the comments. Hence, your mission: comment the program, and fix it so it works as described above! You are to turn in a corrected source program, with comments describing the changes you made to get it to work.
ECS 30-A, Introduction to Programming Spring Quarter 2002 Email: cs30a@cs.ucdavis.edu |