Skip to content

cpp-exercises/Fraction_a

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

7 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Fraction

Write a class named Fraction that represents a fraction of two integers. Overload the following operators for this class:

  • The + operator to add two fractions and return their sum as another fraction in reduced form.
  • The - operator to subtract two fractions and return their difference as another fraction in reduced form.
  • The * operator to multiply two fractions and return their product as another fraction in reduced form.
  • The / operator to divide two fractions and return their quotient as another fraction in reduced form.
  • The == operator to compare two fractions for equality and return true or false.
  • All comparison operations (>,<,>=,<=)
  • The ++ and -- operator that adds (or substracts) 1 to the fraction. implement both pre and post fix.
  • The << operator to print a fraction to an output stream in the format โ€œnumerator/denominatorโ€.
  • The >> operator to read a fraction from an input stream by taking two integers as input.
  • All operators should work on both sides on fractions and floats type variables. on a float var you need use up to 3 digits beyond the desimal point for acuracy.

ื“ื•ื’ืžืื•ืช ืœืคืขื•ืœืช ื”ืžื—ืœืงื” ื ื™ืชืŸ ืœืžืฆื•ื ื‘-Demo.cpp.

ื‘ืฉืœื‘ ื ืขืœื™ื›ื ืœื›ืชื•ื‘ ื›ื•ืชืจื•ืช ื•ื‘ื“ื™ืงื•ืช-ื™ื—ื™ื“ื” ืžืงื™ืคื•ืช.

ื›ื™ืชื‘ื• ืืช ื›ืœ ื”ืงื‘ืฆื™ื ื”ื“ืจื•ืฉื™ื ื›ืš ืฉื”ืคืงื•ื“ื•ืช ื”ื‘ืื•ืช ื™ืขื‘ื“ื• ืœืœื ืฉื’ื™ืื•ืช:

make demo && ./demo
make test && ./test

ืžื•ืžืœืฅ ื’ื ืœื”ืจื™ืฅ:

make tidy
make valgrind

ืฉื™ืžื• ืœื‘: ืื™ืŸ ืœืฉื ื•ืช ืงื‘ืฆื™ื ืงื™ื™ืžื™ื, ืืœื ืจืง ืœื”ื•ืกื™ืฃ ืงื‘ืฆื™ื ื—ื“ืฉื™ื. ืžืขืจื›ืช ื”ื‘ื“ื™ืงื” ื”ืื•ื˜ื•ืžื˜ื™ืช ืžืขืชื™ืงื” ืžื—ื“ืฉ ืืช ื›ืœ ื”ืงื‘ืฆื™ื ื”ืงื™ื™ืžื™ื ืขืœ-ื’ื‘ื™ ื”ืคืชืจื•ืŸ ืฉืืชื ืžื’ื™ืฉื™ื, ื•ืœื›ืŸ ื›ืœ ืฉื™ื ื•ื™ ืฉืชืขืฉื• ื‘ืงื‘ืฆื™ื ื”ืงื™ื™ืžื™ื ื™ื™ืžื—ืง.

ื‘ื”ืฆืœื—ื”

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages