hi! i need help by creating a program that will divide using loops wihout using any division or multiplication sign. the allowed signs are just addition and subtraction. Thank you! i will post my program if someone replies with this.
You are expected to post the code in the first post, but well.
The algo is pretty simple here - remember those multiplication lessons back in elementary school? For a*b you just make a+a addition b times. Similar with division.
yeah. actually, we also need the multiplication process using addition and i've already got that one. but, i still cannot get the algo for division because a/b is not equal to just a-a, b times..- it's zero. please give me the logic here directly..anyway thanks for helping me.. i hope to receive another reply..tnx:)
To divide one number by another you could probably pass both numbers, say a and b, to the function with intention of doing a/b. Check if b is zero, because dividing by zero is undefined. Within the function you can declare two numbers, say c and d, with c being how many times you can substract b from a and still have a number zero or more and d being the remainder (eg, 10/3 = 3 with 1 remainder translates to a = 10, b = 3, c = 3, d = 1). This type of division is called integer math and is how C++ implements the / operator for type int. What you display or return is up to you. In C++ the return is just c and d is ignored, but you can display both within the function, return c only, whatever. Using the above variable names the main part of the function could look like:
c = 0
d = a
while b <= d
d = d - b
display c and d
For Each ctrl As Control In Me.Controls("pnlMainPanel").Controls
If ctrl.GetType Is GetType(System.Windows.Forms.Panel) Then
For Each subCtrl As Control In ctrl.Controls
If subCtrl.GetType Is GetType(System.Windows.Forms.TextBox) Then
If subCtrl.GetType Is ...