Contact: aviboots(AT)netvision.net.il
41,604 questions
54,252 answers
573 users
#include <stdio.h> #include <stdlib.h> int main(void) { int n = 76581; char s[10]; sprintf(s, "%d", n); s[0] = '0'; n = atoi(s); printf("%d\n", n); return 0; } /* run: 6581 */
#include <stdio.h> #include <math.h> int main(void) { int n = 87315; printf("%i\n", (int)log10(n)); printf("%i\n", (int)pow(10, (int)log10(n))); n = n % (int)pow(10, (int)log10(n)); printf("%i\n", n); return 0; } /* run: 4 10000 7315 */