+ 2

Please anyone explain the modules operator (%)

I understand the module as followed int a=10; int b=5; int m; int m=a%b;\\ means m=a-(a/b)*b m=0; is that right? please tell anyone?

5th Sep 2017, 4:23 AM
Ponraj Hbk
Ponraj Hbk - avatar
7 odpowiedzi
+ 8
The modulus operator returns a remainder. It is found in coding (as %) and in math (as a = sign with an extra bar on top, and a (mod (number)) behind) So, a%b. a//b=x a%b=a-x. You ARE right
5th Sep 2017, 4:32 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 5
It is used when you need the remainder
5th Sep 2017, 4:37 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 5
Like if your input only requires to match a number to a particular pattern.
5th Sep 2017, 4:38 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 4
Yes
5th Sep 2017, 5:48 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 2
where I mostly used I mean what is the use?
5th Sep 2017, 4:37 AM
Ponraj Hbk
Ponraj Hbk - avatar
+ 1
so u mean if I want to get my answers with in 0 1 2 3......10 I need to use %10
5th Sep 2017, 4:42 AM
Ponraj Hbk
Ponraj Hbk - avatar