Rational Numbers (Abstract Data Type) |
Consider the ADT Rational, which is a Mathematical concept of a rational number. A rational number is a number that can be expressed as the quotient of two integers. Operations to be performed for implemented Rational numbers are:
|
C Language Code: |
RATIONAL.H |
typedef struct rational rat *makerat(int a,int b) rat *sumrat(rat *x, rat *y) void killrat(rat *n) void printrat(rat *n) rat *reducerat(rat *r) for(;i>1;i--) return(t);
rat *subtractrat(rat *x, rat *y) Get Paid by Reading Ads on your Mobiles rat *multiplyrat(rat *x, rat *y) rat *dividerat(rat *x, rat *y) void ratequal(rat *x, rat *y) } |
RATIONAL.CPP |
#include <stdio.h> void main() printf("\n Enter 2st num and denomentor(n/d):"); // SUM OF Rational nos. printf("\n Display Two Rational No.s sum "); //********* SUBSTRATION OF 2 RATIONAL NOS. q = subtractrat(m,n); printf("\n Display Two Rational No.s Subtraction "); printrat(q) ; killrat(m) ; } |
We are trying to contribute to the net what ever Technical knowledge. I Believe that knowledge increases by spreading and sharing with others.
Showing posts with label Rational Numbers (Abstract Data Type). Show all posts
Showing posts with label Rational Numbers (Abstract Data Type). Show all posts
Tuesday, January 30, 2024
Rational Numbers (Abstract Data Type) - DSTC using C Language
Subscribe to:
Posts (Atom)