Computer Science, asked by excellencemun, 1 day ago

write a program find the remainder of a and b and store it in c​

Answers

Answered by SutariyaPankaj
1

How do I write a Java program to find a remainder of a and b when a is divided by b by using only + and -

Basically division of a/b is consecutive subtraction of the dividend and divisor, till the dividend becomes less than the divisor.

So when I say something like 11/2, it is

11–2=9

9–2=7

7–2=5

5–2=3

3–2=1

As you can see, in the above case we have 5 iterations, and the remaining number is 1. So here the quotient would be 5, remainder is 1.

Similarly if we divide say 12/2 it would be like

12–2=10

10–2=8

8–2=6

6–2=4

4–2=2

2–2=0

hope it helps you

Similar questions