+ 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.

27th Jul 2018, 10:06 PM
Mariana
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.
27th Jul 2018, 10:56 PM
Jax
Jax - avatar
+ 6
Matthias It seems to be what he was looking for. If you have a better example, please tell
28th Jul 2018, 12:39 PM
Jax
Jax - avatar
+ 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
28th Jul 2018, 4:20 PM
Shaif Jwd
Shaif Jwd - avatar
+ 3
Paul Grasser if dividend is smaller than divisor then answer will be dividend. Eg 4%10 = 4 5%10 = 5 8%15 = 8
28th Jul 2018, 5:56 PM
Prateek
Prateek  - avatar
+ 2
Module opreator returns the remainder of the operands. For example- 4%2=0 5%2=1 9%5=4 and so on..
1st Aug 2018, 12:47 PM
manas pandey
manas pandey - avatar
+ 1
Share your code please and what output you expect. Otherwise we cannot help...
27th Jul 2018, 10:35 PM
Matthias
Matthias - avatar
+ 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"
28th Jul 2018, 4:18 AM
Matthias
Matthias - avatar
+ 1
Jax It's nothing against you. I'm just confused why Mariana expected an answer about what was exlcuded in the question 🤔😅
28th Jul 2018, 2:09 PM
Matthias
Matthias - avatar
+ 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
28th Jul 2018, 6:27 PM
Matthias
Matthias - avatar
0
% return remainder value. 5%2 = 1
28th Jul 2018, 12:59 PM
Prateek
Prateek  - avatar
0
I'm confused about this: 4%10 What?! How does that work??
28th Jul 2018, 5:48 PM
Paul Grasser
Paul Grasser - avatar
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
29th Jul 2018, 10:07 AM
Radha Amal Goswami
Radha Amal Goswami - avatar
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
29th Jul 2018, 11:19 AM
Matthias
Matthias - avatar
0
helps you to find reminder. 5/2=2 5%2=1
9th Aug 2018, 7:19 AM
Siddharth
Siddharth - avatar
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 :)
26th Sep 2018, 2:09 PM
Nelly Gevorgyan
Nelly Gevorgyan - avatar
- 2
i
9th Aug 2018, 1:03 AM
Nagireddy Mahisri
Nagireddy Mahisri - avatar