#include #include #define MAX_DIGITS 100 int debug = 1; /* prints a digit in some specified format */ void PrintDigit(int d, int b) { printf(" %d ",d); } int main() { /* variables */ int n, b; int digits[MAX_DIGITS]; printf("Enter decimal integers n and b (separated by space): "); scanf("%d%d",&n,&b); if ( debug ) { printf("n is %d, b is %d\n",n,b); } int col = 0; if ( n == 0 ) { PrintDigit(0,b); } else { while ( n > 0 ) { int d = n % b; digits[col] = d; col++; n = n/b; } // all digits now stored, col is one left of leftmost digit while ( col-- > 0 ) { PrintDigit(digits[col],b); } } return EXIT_SUCCESS; }