Thread: how to get a reduced form

  1. #1
    Registered User
    Join Date
    Feb 2005
    Posts
    11

    how to get a reduced form

    Hello , I have qusetion about how to get the fraction reduced form like ( 2/4 = 1/2) and so on in C++ programming language
    Last edited by silent_eyes; 02-25-2005 at 12:20 PM.

  2. #2
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,401
    The same way you would if you were doing it on paper.
    1) Find the greatest common divisor of the numerator and denominator.
    2) Divide both the numerator and the denominator by the greatest common divisor.
    If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

  3. #3
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398

    Unhappy C++ Doesn't Do Fractions

    C++ doesn’t do fractions (natively). Like a calculator, it can handle integers and floating-point numbers.

    You will have to write your own code to:

    1. Get the user’s input, and separate the numerator and denominator.
    2. Save the numerator and denominator as two different variables.
    3. Manipulate the variables as desired (reduce fraction).
    4. Display the new numerator and denominator so it looks like a fraction.
    Last edited by DougDbug; 02-25-2005 at 01:43 PM.

  4. #4
    Registered User
    Join Date
    Feb 2005
    Posts
    11
    Thanks )

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reopening a form ?
    By Aga^^ in forum C# Programming
    Replies: 1
    Last Post: 02-11-2009, 09:28 AM
  2. Calling datas from another form?
    By Aga^^ in forum C# Programming
    Replies: 2
    Last Post: 02-06-2009, 02:17 AM
  3. Accessing main form from functions in other classes
    By pj_martins in forum C++ Programming
    Replies: 1
    Last Post: 11-05-2004, 09:27 AM
  4. My UserControls dissapear off my form
    By zMan in forum C# Programming
    Replies: 2
    Last Post: 09-15-2004, 08:55 AM
  5. Making an MFC form to suit
    By TJJ in forum Windows Programming
    Replies: 1
    Last Post: 04-17-2004, 11:20 AM