How to determine if an integer is a multiple of 10 (Xcode)?

How can I determine if an integer is a multiple of 10 (i.e. 10, 20, 30, 40, etc.) in Objective-C? Thank.

+3
source share
5 answers
BOOL isMultipleOfTen = !(someInt % 10);
+14
source
if((int)myNumber % 10 == 0){
  // it is
}
else {
  // it isn't
}

its almost the same for all afaik languages

Purely for entertainment @Aurum Aquila

disclaimer - DO NOT! lol ... just a little fun

BOOL isDone = NO;
int multiple = 1;
while(!isDone){
  for(int i = 1; i<11; i++){
    if(i*multiple==(int)numberToCheck){
      if(i==10){
        //is multiple
      }
      else{
        //isn't
      }
      isDone = YES;
    }
  }
  multiple++;
}
+8
source

Aurum:

NSString* aString = [NSString stringWithFormat: @"%d", (int) aNumber];
bool isMultipleOf10 = [aString hasSuffix: @"0"];

, -stringWithFormat: , , , n % 10, .

+1

0,

C

if(no%10==0){

//number in multiple of 10

}
else{//reminder is not 0

//number is not in multiple of 10
}
0

Source: https://habr.com/ru/post/1792762/


All Articles