In a piece of code I came across this operator % called modulo but what exactly is the purpose of it? how dows it work and what does it return? Let's assume I have this piece of code:
a = b % c;
What will a be then if b is 5 and c is 2 and why?
Modulo is the operation which repeatedly subtract c from b until it cannot be done anymore because the result would be less than zero. The result is what's left after doing all the repeated subtractions so if b is 5 and c is 2 then a would be 1. You can read more about that on Wikipedia: https://en.wikipedia.org/wiki/Modulo_operation
Thanks mate, I've learned a lot since I wrote this 🙂
✅ Good and straightforward information
❎ Link to wikipedia