fork download
  1. #include <iostream>
  2.  
  3. int main()
  4. {
  5. int n = 15396042 ;
  6. std::cout << "number: " << n << '\n' ;
  7.  
  8. for( int pow = 0 ; n > 0 ; ++pow )
  9. {
  10. int digit = n%10 ; // least significant (rightmost) digit
  11. n /= 10 ; // divide by 10 to remove the rightmost digit
  12. std::cout << "digit at 10^" << pow << ": " << digit << '\n' ;
  13. }
  14. }
  15.  
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
number: 15396042
digit at 10^0: 2
digit at 10^1: 4
digit at 10^2: 0
digit at 10^3: 6
digit at 10^4: 9
digit at 10^5: 3
digit at 10^6: 5
digit at 10^7: 1