Connecting Tech Pros Worldwide Forums | Help | Site Map

Hexadecimal

Newbie
 
Join Date: Nov 2008
Posts: 1
#1: Nov 17 '08
I'm a beginner and new here. Help can't understand this question.
a program to read 2 characters, and print their value when interpreted as a 2 digit hexadecimal number. Accept upper case letter for value from 10 to 15.
thanks

Ganon11's Avatar
Moderator
 
Join Date: Oct 2006
Location: New York, United States of America
Posts: 3,428
#2: Nov 17 '08

re: Hexadecimal


Are you coding in C or C++?

Do you know what a char is?

Do you know how to read from standard input (i.e. the keyboard)?

Do you know how to print to standard output (i.e. the monitor)?
Moderator
 
Join Date: Mar 2007
Location: North Bend Washington USA
Posts: 5,379
#3: Nov 17 '08

re: Hexadecimal


I suggest you accept two characters and test each one to be a hex digit. If both are, you should be able to convert each character to hex and then add it to your result taking to account the position of the hex character. If you receive:

A6

that is

A * 16 + 6 * 1

Shouldn't be too hard.
Reply