Code:
#include <stdio.h>
void convert(int num, int base)
{
int n;
if (num == 0)
return;
else {
convert(num / base, base);
n = num - num / base * base;
if (n < 10)
printf("%d", n);
else
printf("%c", (65 + n - 10));
}
}
int main(void)
{
int num, base;
char cont = 'y';
while (cont == 'y') {
printf ("Enter a decimal number to convert: ");
scanf ("%d", &num);
printf ("Enter the base to convert the number to: ");
scanf ("%d", &base);
convert(num, base);
printf("\n");
printf ("Do you wish to convert again? ");
scanf ("%c %c", &cont, &cont);
printf ("\n");
}
return 0;
}
gee....thanks for ALL the help there quzah.
if ya ain't got nothing useful to say then don't say anything at all!
and no, I don't expect others to do all my work for me, however sometimes if I'm stuck or running out of town I will turn to others for help, and will return the same.