7 Replies - 11320 Views - Last Post: 24 April 2010 - 12:21 PM Rate Topic: -----

#1 Guest_XWR-AiA*


Reputation:

convert Hex number to decimal and vice versa

Posted 14 April 2010 - 04:40 PM

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.

Is This A Good Question/Topic? 0

Replies To: convert Hex number to decimal and vice versa

#2 CTphpnwb   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3795
  • View blog
  • Posts: 13,738
  • Joined: 08-August 08

Re: convert Hex number to decimal and vice versa

Posted 14 April 2010 - 05:00 PM

And what are you going to do?
:ban:
Was This Post Helpful? 0
  • +
  • -

#3 Guest_XWR-AiA*


Reputation:

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 ?
Was This Post Helpful? 0

#4 CTphpnwb   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3795
  • View blog
  • Posts: 13,738
  • Joined: 08-August 08

Re: convert Hex number to decimal and vice versa

Posted 14 April 2010 - 05:18 PM

Sigh. Try reading the rules.
Was This Post Helpful? 0
  • +
  • -

#5 Aphex19   User is offline

  • Born again Pastafarian.
  • member icon

Reputation: 619
  • View blog
  • Posts: 1,873
  • Joined: 02-August 09

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.
Was This Post Helpful? 0
  • +
  • -

#6 college_trained   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 49
  • Joined: 10-January 10

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.
Was This Post Helpful? 0
  • +
  • -

#7 Guest_for neis*


Reputation:

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.
Was This Post Helpful? 0

#8 jjl   User is offline

  • Engineer
  • member icon

Reputation: 1270
  • View blog
  • Posts: 4,998
  • Joined: 09-June 09

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;


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1