Gamua Tachu wrote:My program works well except that for inputs =and < 16 the output is always 1. Also there is no output for decimal numbers 32, 48, 64 etc which correspond to 20, 30, 40 etc.
I copied your code and tried it out. First of all, it doesn't compile because there's something strange at the end of line 21. After fixing that, I get different results than what you describe here.
For example, for 5 I get "0 5". For 10 I get "1". For 16 I get "1 0". For 32 I get "2 0". The results for 5, 16 and 32 look correct, except that you print a space between the digits. Only the "1" when you enter 10 looks wrong.
Follow in your head what the code does when you would enter 10, or run the program in a debugger, enter 10 and go through the code step by step to find out what happens. You'll discover that it does something else then what you had thought it would do.
The code also looks a bit complicated. There are much simpler and shorter ways to convert a number to a hexadecimal
string.