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
 
Thread 'Star maps using Blender'
Blender just recently dropped a new version, 4.5(with 5.0 on the horizon), and within it was a new feature for which I immediately thought of a use for. The new feature was a .csv importer for Geometry nodes. Geometry nodes are a method of modelling that uses a node tree to create 3D models which offers more flexibility than straight modeling does. The .csv importer node allows you to bring in a .csv file and use the data in it to control aspects of your model. So for example, if you...
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...

Similar threads

Back
Top