How to find the remainder of dividing two numbers without using the modulo operator!!
My teacher gave me this exact exercise and It's only my 5th lecture in a course called programming fundamentals.
I have already tried this equation,
a%b = a - (a/b)*b
but it always returns zero!
I've just tried this
public static void main (String [] args){
int a = 50;
int b = 9;
int c = a%b;
int d = a - (a/b)*b;
System.out.println(c);
System.out.println(d);
}
And it seems to work. What types are your variables?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With