rat - numbers The answer is in its reduced form Rat...

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

/* * File: rat.h * ------------------------------------------------- * This interface provides the functions for the * rational number ADT implementation. */ #ifndef _RAT_H #define _RAT_H typedef struct _ratCDT* Rat; /* * Function: CreateRat * Usage: R = CreateRat(n,d); * ------------------------- * This function creates a new rational number. * Both n is an integer and d is a non-zero integer. * If d is 0, the function prints "Arithmetic Exception * error" and returns NULL. Otherwise, it stores the * the rational number. */ Rat CreateRat(long n, long d); /* * Function: DestroyRat * Usage: DestroyRat(R); * ------------------------- * This function frees memory allocated for the rational * number. */ void DestroyRat(Rat R); /* * Functions: AddRat * SubRat * MulRat * Usage: R = AddRat(R1,R2); * R = SubRat(R1,R2); * R = MulRat(R1,R2); * ------------------------- * These functions perform arithmetic operations * (addition, subtraction, multiplication) on rational

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: * numbers. The answer is in its reduced form. */ Rat AddRat(Rat R1, Rat R2); Rat SubRat(Rat R1, Rat R2); Rat MulRat(Rat R1,Rat R2); /* * Function: DivRat * Usage: R = DivRat(R1,R2); * -------------------------* This function divides two rational numbers. * If R2 is 0, the function prints "Arithmetic * Exception Error" and returns NULL; otherwise, * it returns R1/R2 in its reduced form. * numbers. */ Rat DivRat(Rat R1, Rat R2); /* * Function: PrintRat * Usage: PrintRat(R); * -------------------------* This function displays a rational number * in the form "numerator/denominator". * The denominator is always printed as a positive * integer. If numerator/denominator is negative, * numerator is printed as -numerator/denominator; * and not numerator/-denominator. Also if * denominator is 1, "numerator" is printed. If * "numerator" is 0, 0 is printed. */ void PrintRat(Rat R); #endif...
View Full Document

This note was uploaded on 01/17/2012 for the course CSC 1254 taught by Professor Blanks,l during the Fall '08 term at LSU.

Page1 / 2

rat - numbers The answer is in its reduced form Rat...

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

View Full Document
Ask a homework question - tutors are online