splitint.c (551B)
1 /* Exercise 5.22 */ 2 3 #include <stdio.h> 4 5 void splint(int); /* splint :-) */ 6 7 int main() 8 { 9 int num = 0; 10 11 while(num < 1 || num > 32767) { 12 printf("Give me an integer between 1 and 32767: "); 13 scanf("%d", &num); 14 } 15 16 splint(num); 17 18 return 0; 19 } /* E0F main */ 20 21 /* Split an integer in the range 1-32767 */ 22 void splint(int n) 23 { 24 int i, check = 0; 25 26 for(i = 10000; i >= 1; i /= 10) { 27 if(n / i % 10 != 0) 28 check = 1; 29 if(!check) 30 continue; 31 32 printf("%d ", n / i % 10); 33 } 34 printf("\n"); 35 36 } /* eof splint() */ 37