Remember that division is just repeated
subtraction.
I'm going to modify your example by one.
64 ÷ 12
64 - 12 = 52 (subtracted 12 one time)
52 - 12 = 40 (subtracted 12 two times)
40 - 12 = 28 (subtracted 12 three times)
28 - 12 = 16 (subtracted 12 four times)
16 - 12 = 4 (subtracted 12 five times)
4 < 12, so I cannot subtract any more twelves.
Therefore, 64 ÷ 12 = 5 with a remainder of 4.
[edit]
Oh, also, the & indicates a
reference.
https://isocpp.org/wiki/faq/references#overview-refs
I would rewrite your main function as:
1 2 3 4 5 6 7
|
int main()
{
int q, r;
divide(65,12,q,r);
cout << "65 / 12 = " << q << " with a remainder of " << r << ".\n";
return 0;
}
|
Hope this helps.