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.
convert Hex number to decimal and vice versa
Page 1 of 17 Replies - 5693 Views - Last Post: 24 April 2010 - 12:21 PM
#1 Guest_XWR-AiA*
convert Hex number to decimal and vice versa
Posted 14 April 2010 - 04:40 PM
Replies To: convert Hex number to decimal and vice versa
#2
Re: convert Hex number to decimal and vice versa
Posted 14 April 2010 - 05:00 PM
And what are you going to do?
#3 Guest_XWR-AiA*
Re: convert Hex number to decimal and vice versa
Posted 14 April 2010 - 05:14 PM
all what i meant i that i need help with this assignment ,, that's y i asked in the 1st place ?
#4
Re: convert Hex number to decimal and vice versa
Posted 14 April 2010 - 05:18 PM
Sigh. Try reading the rules.
#5
Re: convert Hex number to decimal and vice versa
Posted 14 April 2010 - 05:49 PM
Just show us what you have done and what you know so far.
#6
Re: convert Hex number to decimal and vice versa
Posted 14 April 2010 - 06:16 PM
I think what they are trying to say is show the effort you've put into this assignment so far. The contributors here are not here to do your homework for you. They will help if you are having trouble with something though.
My suggestion is, if you don't already know how to convert between the two on paper, learn that first. If you do know how to, then write down the process in which you would convert step-by-step. Then start coding from there.
I think this is a great assignment as I have been working on this type thing but on a bigger scale (converting between Binary, Octal, Decimal, and Hex) all in one program.
My suggestion is, if you don't already know how to convert between the two on paper, learn that first. If you do know how to, then write down the process in which you would convert step-by-step. Then start coding from there.
I think this is a great assignment as I have been working on this type thing but on a bigger scale (converting between Binary, Octal, Decimal, and Hex) all in one program.
#7 Guest_for neis*
Re: convert Hex number to decimal and vice versa
Posted 24 April 2010 - 12:16 PM
strstream can be handy.Just check it out.Specifically look for the manipulators like hex and octa.
#8
Re: convert Hex number to decimal and vice versa
Posted 24 April 2010 - 12:21 PM
take a look at std::hex
cout<<std::hex<<15<<endl;
Page 1 of 1
|
|

New Topic/Question
Reply
MultiQuote








|