Fractions

This is a discussion on Fractions within the C++ Programming forums, part of the General Programming Boards category; Hi, I am having a problem with fractions in my class. The problem is to create a member function to ...

  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,136
    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, 04:10 AM
  3. Need help woth fractions..
    By snapshooter in forum C Programming
    Replies: 4
    Last Post: 11-17-2004, 05:51 PM
  4. Greatest Common Factors of Fractions
    By sonict in forum C++ Programming
    Replies: 1
    Last Post: 01-15-2003, 03:33 AM
  5. Decimals to Fractions
    By ToasterPas in forum C++ Programming
    Replies: 4
    Last Post: 12-28-2001, 11:58 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21