Please Help

This is a discussion on Please Help within the C++ Programming forums, part of the General Programming Boards category; I need help with programming because its almost the end of the semester and I still have no clue how ...

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

    Please Help

    I need help with programming because its almost the end of the semester and I still have no clue how to write code. My professor gave us an assignment and I dont know how to do it so if you could help me I would greatly appreciate it. Here is the code.

    Write a program that will reduce a fraction to its lowest components.
    First, write a function greatest common divider that takes two integer arguments, u and v, and does the following computation:
    Step1: If v is zero, return zero.
    Step2: Set u=|u| and v=|v|.
    Step3: If u is zero, return zero.
    Step4: Set r=u mod v, u=v, v=r, and return to step3.
    The results is the greatest common divisor of u and v.
    Write a main function that will let you enter two intergers repeatedly. End the loop if one of the intergers is zero.
    For the two intergers entered, find the greatest common divisor, divide it into the two intergers, and display the results.

  2. #2
    Let's do some coding! Welshy's Avatar
    Join Date
    Mar 2005
    Location
    Staffordshire University, UK
    Posts
    168

  3. #3
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Location
    Manassas, VA USA
    Posts
    903
    send what you think to be a proper amount of cash to this paypal account: <<SNIPPED by moderator>>
    Last edited by Salem; 04-12-2005 at 11:51 AM. Reason: Remove email address soliciting for payment
    • "Problem Solving C++, The Object of Programming" -Walter Savitch
    • "Data Structures and Other Objects using C++" -Walter Savitch
    • "Assembly Language for Intel-Based Computers" -Kip Irvine
    • "Programming Windows, 5th edition" -Charles Petzold
    • "Visual C++ MFC Programming by Example" -John E. Swanke
    • "Network Programming Windows" -Jones/Ohlund
    • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
    • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel

  4. #4
    Let's do some coding! Welshy's Avatar
    Join Date
    Mar 2005
    Location
    Staffordshire University, UK
    Posts
    168
    lol, now now brain, we cant be having that sort of behaviour

  5. #5
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Location
    Manassas, VA USA
    Posts
    903
    my bad.. from the first post, i thought this was the, "programmer for hire" forum
    Last edited by The Brain; 04-12-2005 at 11:54 AM.
    • "Problem Solving C++, The Object of Programming" -Walter Savitch
    • "Data Structures and Other Objects using C++" -Walter Savitch
    • "Assembly Language for Intel-Based Computers" -Kip Irvine
    • "Programming Windows, 5th edition" -Charles Petzold
    • "Visual C++ MFC Programming by Example" -John E. Swanke
    • "Network Programming Windows" -Jones/Ohlund
    • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
    • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,845
    Damn right we can't!
    Glares disapprovingly @ brain
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  7. #7
    Tropical Coder Darryl's Avatar
    Join Date
    Mar 2005
    Location
    Cayman Islands
    Posts
    503
    You lay out the steps 1,2,3,4. Add a few parenthesis and semi-colons and you have it.
    the only other thing you might need to know x mod y = x%y and |x| = abs(x)

Popular pages Recent additions subscribe to a feed

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