#include <stdlib.h>
#include <stdio.h>
#define SIZE 25
int main (void)
{
int d, b, c;
printf(" Enter an integer and press 'enter':
");
scanf("%d" , &d);
printf(" Enter the desired base and press 'enter':
");
scanf("%d" , &b);
if (b < 2) {
printf(" Your base is to low!
")
} else {
while (d != 0) {
int radix;
radix = d % b;
d = d / b;
char basechars[] = "0123456789ABCDEF";
printf("%c" , basechards[radix]);
}
}
return 0;
}
This Program prompts the user for a decimal and a base to convert that decimal to the base that has been chosen. The conversion is however printed in reverse order and I need it to print regular. Example: Entered: 112, then entered 16, result is 07 rather than 70.
See Question&Answers more detail:os