Goal C: How do I know if a number is divisible by another number?

In the c lens (Mac development). How can I find out if a number is divisible by another number, not decimal?

+7
objective-c macos
source share
2 answers

Assuming you are dealing with integers, use the module function:

if ((a % b) == 0) { // A is divisible by B } else { // A isn't divisible by B } 
+31
source share

I am not an objective c programmer, but in general, just checking if A mod B = 0 ... should it work in OC?

greetings.

+4
source share

All Articles