cAn any one help me.... i am doing a program to change
(1) decimal to binary
(2) decimal to octal
(3) decimal to hexadecimal
i dun know to do option 3 care to help.....
THIS is The coDing attached...
cAn any one help me.... i am doing a program to change
(1) decimal to binary
(2) decimal to octal
(3) decimal to hexadecimal
i dun know to do option 3 care to help.....
THIS is The coDing attached...
you dont convert remainders < 10 to chars in DecToHex()
use
KurtCode:else { remainderchar=remainder + '0'; }
In addition to the change ZuK suggested you should also change this code:
with the code:Code:temp=temp/16; remainder=temp%16;
In other words invert the two operations. You first get the current remainder, than update (divide) the number so that in the next cycle you'll get the next remainder.Code:remainder=temp%16; temp=temp/16;
Hi guys.. it dun work again... can someone edit and attach it again.. with comments where the code was changed....
No one is here to do the work for you, learn how hex and dec work (and how to inter convert between the two) before going any further.
hi there i got it working.. bb\ut when i retry the option again.. the output does show the same value as my first attempt....
If it's a C program, why the cpp extension? Some compilers might attempt to compile your code as C++ based upon the extension, which can cause some problems for you.
Guessing is no way to learn C.