Yaşar.R Yaşar.R -4 years ago 159
C Question

base conversion in c programming language

could anyone point out what is wrong with this piece of code?? I'm trying to write a simple(without using arrays and stuff like that) program that would convert the base 10 numbers to any other base. i'm a beginner, I've just started coding in C

PS: As you can see i haven't written anything that would inverse the results, and i didn't receive any outputs from the compiler. it stopped working.

int a,b,c;
printf("Please enter a number in base 10: ");
printf("\nPlease enter the base that you want the number to be converted to: ");

Answer Source

Change your while loop to a != 0. You want to loop until you have reduced the input number to zero. Your code is terminating when the first digit is 0.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download