3
Reply

What does the % operator exactly do?

Wigger Tolsma

Wigger Tolsma

11 years ago
952
Today I had an assignment that told me to only allow numbers through that are a multiplication of 5.
After looking around on the internet I found the % operator. I thought this operator only removed the decimals, for example 5 % 2 equals 2.
But I could use it in my program as if(iWithdraw % 5 == 0){do this and that}.
I'm glad it worked but I still don't know why it worked haha.
Can someone explain this to me?

Answers (3)