revint.c (529B)
1 /* Exercise 5.28 */ 2 3 #include <stdio.h> 4 #include <math.h> 5 6 void revint(int); 7 8 int main() 9 { 10 int number; 11 12 printf("Give me a number: "); 13 scanf("%d", &number); 14 15 revint(number); 16 printf("\n"); 17 18 return 0; 19 } /* E0F main */ 20 21 /* print a int to reverse */ 22 void revint(int num) 23 { 24 int i; 25 26 if(num > pow(10, 9)) { 27 printf("Number is too large!"); 28 return; 29 } 30 for(i = 1; i <= pow(10, 8); i *= 10) { 31 if(num / i % 10) 32 printf("%d", num / i % 10); 33 } /* end for (i) */ 34 35 } /* eof revint() */ 36