0
Task 3%6, output 3. How come?
Task 3%6, output 3. How come?
5 Answers
+ 1
% first divide the number an then return the reminder so if we want to divide 3 by 6 first we should multiple 6 by zero then we need to subtract 3 by zero which will have the reminder of 3 :
3 / 6
-> 6 X 0 = 0
-> 3 - 0 = 3
-> reminder is 3
+ 4
Anna Pavlova
% is known as modulus operator which returns reminder so here reminder will be 3
3 % 6 = 6 * 0 + 3 = 3
+ 1
% operator gives remainder after division
So 6 % 3 when u divide the quotient will be 0 and remainder will be 3
So ans will be 3
+ 1
6 ) 3 (0
0
---------------
3
3/6 as quotient is 0(full int) . so the remaining remainder is 3 itself.
+ 1
% is modulus meaning returns the remainder.
___________
divisor | divident | quotient
x
- - - - - - - - - -
remainder
example: 3%6
___
6 | 3 | 0
0
- - -
3 - > so this is remainder and hence the result to 3%6