pa4 - COP 3275 Programming Using C Language Fall 2011...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
COP 3275 Programming Using C Language Fall 2011, Programming Assignment #4 Yi Wang Radhika Medury Min Chen [email protected] [email protected] [email protected] Due Date: Wed. Nov 16, 2011 @ 12:00pm (noon) NO Late submission is accepted! Problem description: Write a program that asks the user to enter a fraction of two nature numbers, and then reduces the fraction to lowest terms: Enter a fraction of natural numbers: 18/6 The lowest term is: 3/1 Note: You’re required to check the validity of the input, i.e. the input should be non-negative and the denominator should ≠ 0. If not, print a hint and let the user re-input. Hints : 1. Use a loop to check the numbers until they are valid. 2. To reduce a fraction, first compute the greatest common divisor (GCD). A classic algorithm for computing GCD is the Euclidean algorithm. It goes as follows: Let and ± be the two numbers, ² ³´ ²± . Compute the remainder when is divided by ± . Copy ± into and copy the remainder into ± . If
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/30/2011 for the course COP 3275 taught by Professor Jonathanliu during the Fall '11 term at University of Florida.

Page1 / 2

pa4 - COP 3275 Programming Using C Language Fall 2011...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online