CS010 Assignment 1

Very Simple C Programs

Due: January 9, 2001, 10:00 AM

This assignment should be turned in for evaluation. You must work individually on this assignment. Any unauthorized collaboration is a violation of the Honor Code. To turn in the assignment, you will use the turnin command:

turnin -c 010 file.c

where you substitute the name of your file for file.c. You may turn in the same file more than once, which will overwrite the earlier version. You may want to do this if you discover a mistake or make an improvement after turning in your assignment.

 

  1. Do Exercise 3 from Chapter 6 of King. Call the file reduce.c. Your program should use a function to compute the GCD. The function prototype should look like this:
    int gcd(int, int);
  2. Modify your answer to the first question to have a main loop, where the user is continually prompted for input until an invalid fraction is encountered (a denominator of 0). Call this file reduce_loop.c.