+ 6
Function of module (%)
I don't understand how it works. I got that is the remainder but when the program runs I don't get the answer I think is it.
16 Answers
+ 8
Think of it like this:
a = 5
b = 9
b % a is basically the same as taking the leftover from b / a. a goes into b 1 time, and has 4 left over, therefore your number would be 4.
if you need any extra help, please share your code.
+ 6
Matthias
It seems to be what he was looking for. If you have a better example, please tell
+ 4
Its basically used to find out remainder of 2 numbers.
For example: if we have
a=10
b=3
If the question is written as 10%3, means the number remaining after division will be your remainder. The answer here is 1
+ 3
Paul Grasser if dividend is smaller than divisor then answer will be dividend. Eg
4%10 = 4
5%10 = 5
8%15 = 8
+ 2
Module opreator returns the remainder of the operands.
For example-
4%2=0
5%2=1
9%5=4
and so on..
+ 1
Share your code please and what output you expect. Otherwise we cannot help...
+ 1
That's exactly the remainder, this part seems to be understood already. So you just explained what was known and got best answer? Lol, I don't get the posters question then.
It's like asking: "I understand A, but I don't understand A"
+ 1
Yes, because e.g. for 4%10
4 = 0*10 + 4
-> remainder is 4
and e.g. for 10%4
10 = 2*4 + 2
-> remainder is 2
0
% return remainder value.
5%2 = 1
0
I'm confused about this:
4%10
What?!
How does that work??
0
the function of module is used to obtain a remainder value when one value is divided by the other
like say a=6,b=5
therefore a%b=1because when we divide 6 by 5 we obtain 1 as remainder. In java while using this operator the bigger value must be stated before the operator always
0
moaid razhy No, that's wrong.
The remainder is 4, because 10 fits one time in 14 and leaves 4 as a rest:
14 = 1*10 +4
Other example:
5/3 = 1.6666666...
But the remainder is not 0.666666...
It is 2, because
5 = 1*3 + 2
0
helps you to find reminder.
5/2=2
5%2=1
0
The remainder of division
if 9%4 =1 how it's work?
9 is 2*4 + 1 , that why 1.
more ex. 10%3=1 (10 is 3*3 + 1 )
8%6=2 ( 8 is 6*1 + 2)
6%10=6 (6 is 10*0 + 6)
For more info write me :)
- 2
i