hello friend,
how to convert decimal to hexa decimal i c.
if possible, give me example program.
Printable View
hello friend,
how to convert decimal to hexa decimal i c.
if possible, give me example program.
If you just want to print an int in hexadecimal format, then use %x or %X as the format specifier.
Yeah well, we don't do your homework for you!
Besides, hexadecimal format is a way of *displaying* a number. When you declare an int for example, the number is stored in binary, when you print it out it's explicitly converted to decimal. What I'm trying to say is that you can't store a hexadecimal number.
Unless you're trying to convert a number into a string, which holds the hexadecimal representation, in that case I'd scour previous threads on this forum.
QuantumPete
If you don't know how to do it away from a computer, I suggest you get reading. It's pretty simple stuff:
Code:To convert a number from base n to 10:
eg) say the number is 12345 where n >= 6 (key n^{4} = n to the power of 4)
answer: (5 x n^{0}) + (4 x n^{1}) + (3 x n^{2}) + (2 x n^{3}) + (1 x n^{4})