fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3. int main(){
  4. int n = 0;
  5. int i = 0;
  6. int j = 0;
  7. int k = 0;
  8. int output2 = 0;
  9. int count = 0;
  10.  
  11. printf("Number? > ");
  12. scanf("%d", &n);
  13.  
  14. i = n;
  15. j = n;
  16.  
  17.  
  18. while (i){
  19. i = i/10;
  20. count++;
  21. }
  22.  
  23.  
  24. printf("Foward direction \n");
  25. while (count > 0){
  26. k = j;
  27. k /= pow((double)10, count - 1);
  28. output2 = k % 10;
  29. if (output2 >= pow((double)10, count - 1)){
  30. printf("Last digit: %d \n", output2);
  31. }
  32. else {
  33. printf("Digit: %d \n", output2);
  34. }
  35. count -= 1;
  36. }
  37.  
  38. return 0;
  39. }
Success #stdin #stdout 0s 1792KB
stdin
100000
stdout
Number? > Foward direction 
Digit: 1 
Digit: 0 
Digit: 0 
Digit: 0 
Digit: 0 
Digit: 0