This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: which can be simplified by finding the gcd of the numerator and denominator. Write the gcd function using recursion . Your program should be able to store any number of Fractions in a dynamic array. Find the sum of them using a simple loop, assuming that there are more than 2 input fractions. Remember to free the array after use. Enter number of Fractions: 5 Enter Fraction 1: 1 5 6 Enter Fraction 2: 3 2 3 Enter Fraction 3: 2 1 2 Enter Fraction 4: 0 1 6 Enter Fraction 5: 0 2 3 Their sum is 8{5/6} Notice: 1: Please just hand in source code file (.cpp). The filename should be “assignmentFive.cpp”. 2: The statement “system ("PAUSE")” should be removed. The following is a nonrecursive gcd function. (For you start writing your program even recursion has not been discussed. In final program please use recursion function ) int gcd(int a, int b) { while (b != 0){ int t; t = b; b = a % b; a = t; } return a; }...
View Full
Document
 Spring '11

Click to edit the document details