+ 2
The use of math in coding
How should i know when to use "/" and "%"
2 Réponses
+ 7
If you wanna retrieve "Quotient" use /, and if you wanna retrieve "Remainder" use %.
Example:
10 / 5 = 2 [ the quotient ]
10 % 5 = 0 [ the remainder ]
We use mod (%) to check whether the number1 is fully divisible by number2. In our case numbers were 10, 5.
In conclusion I just wanna say please try "FizzBuzz" code solution.
0
Depends on your usecase
% is modulo operator
/ Is dividing
When % is used, you get quotient and remainder