A Help!

This is a discussion on A Help! within the C Programming forums, part of the General Programming Boards category; I've got this assignment to be completed. Kindly help: A kid was asked to simplify 26/65. He simply cancelled tenchnique ...

  1. #1
    Registered User
    Join Date
    Sep 2011
    Posts
    2

    Exclamation A Help!

    I've got this assignment to be completed. Kindly help:
    A kid was asked to simplify 26/65. He simply cancelled tenchnique produced result 26/65 = 2/5 (Cancellation of 6)
    Write a program to determine all fractions with two digit numertors and denominators for which the kid's technique work correctly.

    Having a tough time to solve this example.

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Well, thing is, we're not here to do your math homework for you.... Work the problem and when you have some code, you can post about any problems you may be having. Show us your code, ask specific questions and we'll see what we can do...

    Homework Policy

  3. #3
    Registered User
    Join Date
    Sep 2011
    Posts
    2
    Okay. I know. Wait. I am beginner in learning C programming. I'll be glad if you elaborate your answer. Take pain to write some initials or hint?

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,647
    Quote Originally Posted by unevenblue
    take pain to write some initials or hint?
    E's algorithm to compute the GCD.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by unevenblue View Post
    Okay. I know. Wait. I am beginner in learning C programming. I'll be glad if you elaborate your answer. Take pain to write some initials or hint?
    What you have is a math problem... when you understand how to solve it by pencil and paper, you will also have a good start on writing the code. Programmers don't simply get handed assignments and sit down to write code... the problem being that nobody, no matter how skilled, can write the solution to a problem they don't understand.

    This isn't the math department...

  6. #6
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    So you need to generate two numbers with a digit in common, then check whether removing the common digit gives you the same fraction as the original.

    (Math note: If you want to check whether a/b = c/d, then you actually check whether a*d = b*c, so that you don't have to deal with floating-point inaccuracies, et cetera.)

    You'll probably generate your pairs of numbers with some for-loops (one to go through all the possible common digits, one to go through the other digit on top, one to go through the other digit on the bottom).

Popular pages Recent additions subscribe to a feed

Tags for this Thread


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