+ 2

The use of math in coding

How should i know when to use "/" and "%"

14th Oct 2024, 12:29 AM
carlo jose santos
carlo jose santos - avatar
2 Answers
+ 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.
14th Oct 2024, 1:59 AM
Luo Shenshi
Luo Shenshi - avatar
0
Depends on your usecase % is modulo operator / Is dividing When % is used, you get quotient and remainder
16th Oct 2024, 9:03 AM
Sharpneli
Sharpneli - avatar