Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Little man computer help

  1. Nov 1, 2007 #1
    little man computer....help plzzz....urgent

    can some1 pl help me write a program to perform the integer division of two numbers (dividend=divisor*quotient+remander). DIvidend and Divisor should be provided by the user, and the quotient and the remainder should be returned to the user. the user must also supply any numbers that may be required.


    thanxx in advance
     
  2. jcsd
  3. Nov 1, 2007 #2

    PhY

    User Avatar

    Well depends what Language you're Writing in.

    If it was Turbo pascal.
    program div;
    uses crt;
    var
    a:Integer;
    b:integer;
    c:integer;
    begin

    writeln ("Division of 2 numbers");
    repeat
    write (' Enter 2 numbers to divide by :');
    read(a,b);
    until (a,b<>0);
    C:=a/b;
    Writeln (' Division of ',a,' by ',b,' := ,'c);
    readln;

    end;

    Btw ..I haven't wrote pascal in 2 years sooo....not Snippet proof.
     
  4. Nov 1, 2007 #3
    if it is in c++ you would do something like
    int dividend;//given by the user somehow
    int divisor;//given by the user somehow
    int quotient = dividend/divisor;//performs integer division you'll get the right number
    int remainder = dividend%divisor;//Modulus operator, gives you the remainder
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: Little man computer help
  1. Little man computer (Replies: 6)

  2. A little C# help. (Replies: 7)

Loading...