0

How to remove zeros at the end of an integer?

1200 op is 12 8000 op is 8 56780 op is 5678

11th Aug 2018, 2:26 PM
Mallika Das
Mallika Das - avatar
1 Odpowiedź
+ 5
Repeatedly check the divisibility of the number by 10. If it is divisible, then divide it by 10 and store the value for the next evaluation cycle. while ( !(number % 10) ) number /= 10;
11th Aug 2018, 2:33 PM
Babak
Babak - avatar