Advertisement
mahatma_xande

ex05lista05

Aug 21st, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.35 KB | None | 0 0
  1. /*
  2. It prints separately and in a forward fashion all digits of a given non-negative integer number.
  3. */
  4.  
  5. #include <stdio.h>
  6.  
  7. int main(){
  8.    
  9.     int x;
  10.     int y;
  11.     int k = 10;
  12.    
  13.     printf("Enter x: ");
  14.     scanf("%d", &x);
  15.    
  16.     while((x/k) >= 1){
  17.         k = k * 10;
  18.     };
  19.  
  20.     while(k > 1){
  21.         k = k/10;
  22.         y = x/k;
  23.         printf("%d\n", y);
  24.        
  25.         x = x - y * k;
  26.     }
  27.    
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement