Hi, I have following problem.
I should write program, that will divide 2 given numbers from console and display every step I've done.
For example.
Write 2 numbers:
546 37
546 : 37 = 14
-37
176
-148
28 rest
Write 2 numbers:
1000 10
1000 : 10 = 100
-10
0
0
0
0
0 rest
-------
To be more specific...I even don't know, how to begin, so I'll appreciate any good advice. Thx
This code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
#include <iostream>
using namespace std;
int main()
{
int a,b;
cout << "Write 2 numbers: ";
cin >> a >> b;
cout << a << " : " << b << " = " << (int) a/b << "\nrest " << a%b << '\n' ;
system("Pause");
return 0;
}
|
will display:
Write 2 numbers: 546 37
546 : 37 = 14
rest 28
|
but doesn't show the calculation process.
Last edited on
thx for reply
Nevertheless, I still don't know how to display division process.
Any other ideas?
Oops - what do you mean process?
Last edited on
546 : 37 = 14
-37
176
-148
28 rest
I call "process" lines below 546 : 37 = 14, so:
-37
176
-148
Calculation of result and rest is simple