Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

// This is the pseudocode for an ‘iterative’ binary search procedure CSC 219: Programing in C Lab 8 20 Points Due Apr 07, 2022 Using structs A rational number is defined by a numerator and...

1 answer below »

This is the pseudocode for an ‘iterative’ binary search procedure
CSC 219: Programing in C
Lab 8
20 Points
Due Apr 07, 2022
Using structs
A rational number is defined by a numerator and denominator, where the denominator is not 0. ½, 6/1 and -5/4 are all rational numbers. Declare a struct rational to hold a rational number. Write four functions using the struct type that you declared.
1. An input function: This function takes a pointer to the struct type that you declared. The function prompts the user for two integers and puts them into the struct.
2. An output function: This function takes a pointer to the struct type that you declared. The function prints the number as: numerator / denominator.
3. An add function: This function takes three pointers to the struct type that you declared. Two pointers are to the operands and the third function is for the result.
4. A multiply function: This function takes three pointers to the struct type that you declared. Two pointers are to the operands and the third function is for the result.
5. Write a main function with a loop to test your functions.
Sample output might look like this:
Do you want to run the program (y/n): y
Enter the numerator: 2
Enter the denominator: 3
Enter the numerator: 1
Enter the denominator: 5
Enter 1 for add and 2 for multiply: 1
The answer is 13 / 15
Do you want to run the program (y/n): y
Enter the numerator: 2
Enter the denominator: 9
Enter the numerator: 3
Enter the denominator: 4
Enter 1 for add and 2 for multiply: 2
The answer is 6 / 24
Do you want to run the program (y/n): n
Have a nice day.
Note: Do not do any e
or checking for improper input. Just don’t make input mistakes. Do not wo
y about reducing the number to lowest terms.
PAGE
1
Answered Same Day Apr 18, 2022

Solution

Kshitij answered on Apr 19 2022
88 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here