Thread: Fractions

  1. #1
    Unregistered
    Guest

    Fractions

    Hi,
    I am having a problem with fractions in my class. The problem is to create a member function to add two fractions and create a member function to subtract two fractions, so far I get..

    class fraction{
    private:
    int Whole;
    int Numerator;
    int Denominator;
    };

    int fraction::AddFraction( int x, int y)
    {
    }

    int fraction::SubstractFraction(int x, int y)
    {
    }

    but I cant seem to do the math for the fractions. Can someone help. Thanks

  2. #2
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,138
    1) Must have same denominator (if not =, multiplying denominators will give a common denominator)

    2) After added/subtracted, you can reduce

    3) Can you use improper fracts, it will be easier?

  3. #3
    Unregistered
    Guest
    Thanks, that helps alot
    -nika

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. fractions
    By zdream8 in forum C Programming
    Replies: 2
    Last Post: 05-21-2008, 09:54 PM
  2. Algebraic Fractions
    By treenef in forum C++ Programming
    Replies: 8
    Last Post: 12-20-2005, 05:10 AM
  3. Need help woth fractions..
    By snapshooter in forum C Programming
    Replies: 4
    Last Post: 11-17-2004, 06:51 PM
  4. Greatest Common Factors of Fractions
    By sonict in forum C++ Programming
    Replies: 1
    Last Post: 01-15-2003, 04:33 AM
  5. Decimals to Fractions
    By ToasterPas in forum C++ Programming
    Replies: 4
    Last Post: 12-28-2001, 12:58 PM