C/C++ Help writing a C++ program for integer division with user input

  • Thread starter Thread starter thatspreets
  • Start date Start date
  • Tags Tags
    Computer
AI Thread Summary
The discussion revolves around writing a program for integer division using the Little Man Computer (LMC) model. The user seeks assistance in creating a program that takes two numbers—the dividend and divisor—inputted by the user and returns the quotient and remainder. Several programming languages are mentioned, with examples provided for Turbo Pascal and C++. In Turbo Pascal, the program prompts the user for two numbers, checks for non-zero values, and performs the division. In C++, the program uses integer division and the modulus operator to calculate the quotient and remainder. The conversation highlights the need for user input and basic error handling in the program.
thatspreets
Messages
1
Reaction score
0
little man computer...help pleasezz...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
 
Technology news on Phys.org
Well depends what Langauge 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.
 
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
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...

Similar threads

Back
Top