# help with hex to dec converter ??

Printable View

• 04-17-2010
XWR-AiA
help with hex to dec converter ??
hello there ,, ^_^

i need help with this,,, i can't get it ,, i don't know y ,, maybe because i can't create a function can convert from something to other ,, ^_^

i really need your help with this one ,, ^_^

btw i am new here and kindda like it ,, ^_^

Quote:

Write a program that able to convert Hex number to decimal and vice versa. The program should
have two functions. The first function called hexToDec takes one argument as string and returns
an integer. The second function called decToHex takes also one argument as integer and returns
a string. The program should offer the user two options:
1. To convert Hex to Dec.
2. To convert Dec to Hex.
Example:
Please choose one of the following:
1- Convert Hex to Dec.
2- Convert Dec to Hex.
1
Please enter a Hex number:
2A
2A = 42 in Decimal.
====================================
Please choose one of the following:
1- Convert Hex to Dec.
2- Convert Dec to Hex.
2
Please enter a Dec number:
2748
2748 = ABC in Hex.
Assume that all Letters are in capital letters so you do not need to worry about small letters too.
• 04-17-2010
tabstop
Do you yourself (without mechanical aids except perhaps a four-function calculator) know how to convert 2748 to hexadecimal?
• 04-17-2010
XWR-AiA
i know how to convert it on a paper but i don't know how to write it as a program ,, ??
• 04-17-2010
tabstop
Well, that's the catch: they're exactly the same. However you do it on paper, that's how you have your program do it. So if you can write your steps down in order, you'll have pseudocode; and you can then turn that pseudocode into a function. So start by writing your process down, and be as clear as you can.
• 04-17-2010
jeffcobb
Quote:

Originally Posted by XWR-AiA
i know how to convert it on a paper but i don't know how to write it as a program ,, ??

What programming classes have you had? I am not being facetious; this is a core and very basic task in programming and hence there are 101 ways of doing it (assembly, C, C++, etc). Do you know how to create functions in general? That might be a place to start. If you want to cheat, google for snippets.org and dig around there; I promise you will find what you need but you won't learn anything unless you do it yourself...