Thread: Converting hex to binary

  1. #1
    Registered User
    Join Date
    Mar 2010
    Location
    bbsr,odisha,india
    Posts
    27

    Smile Converting hex to binary

    Can anyone please tell me a c++ program to convert a given hexadecimal no. to binary?
    Also, vice-versa?

  2. #2
    Registered User
    Join Date
    Aug 2003
    Posts
    1,218
    Or better yet, you do it and learn something in the process. Start out and we can help with specific problems you are having. This also smells like homework: C Board - Announcements in Forum : General Programming Boards

  3. #3
    Registered User
    Join Date
    Mar 2010
    Location
    bbsr,odisha,india
    Posts
    27
    Quote Originally Posted by Shakti View Post
    Or better yet, you do it and learn something in the process. Start out and we can help with specific problems you are having. This also smells like homework: C Board - Announcements in Forum : General Programming Boards
    actually i have the basic logic outline behind it.Since i am a beginner, i need to know the syntax.
    No,your nose is malfunctioning.It is not at all homework.Actually i have learnt C programming but not C++.I have written a c program on this.Now i want to write one in C++.Please help

  4. #4
    Registered User
    Join Date
    Aug 2003
    Posts
    1,218
    So show us what you have then.

  5. #5
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    A switch statement with 16 cases would do it.
    It would also help you memorize the conversion.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  6. #6
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by suryap.kv1bbsr View Post
    actually i have the basic logic outline behind it.Since i am a beginner, i need to know the syntax.
    As the others are saying... you need to LEARN the syntax, not have it handed to you.

  7. #7
    Registered User
    Join Date
    Mar 2010
    Location
    bbsr,odisha,india
    Posts
    27
    thanks everybody for ur support....
    Can anyone suggest me a free ebook where i can learnC++syntax?Although i found a lot in the web, i want the best one,where evrything is explained nicely

  8. #8
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Here ya go...

    C++ Book Recommendations

    Listed at the top of the message list on this very forum

    I'm presently grinding my way through Thinking in C++...

  9. #9
    The Dragon Reborn
    Join Date
    Nov 2009
    Location
    Dublin, Ireland
    Posts
    629
    Do you mind videos...?
    If you don't... YouTube - C++ Tutorial (1) - Absolute n00b spoonfeed
    You ended that sentence with a preposition...Bastard!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Converting a binary string to hex
    By maxhavoc in forum C++ Programming
    Replies: 6
    Last Post: 07-25-2006, 12:46 PM
  2. Replies: 11
    Last Post: 03-24-2006, 11:26 AM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  4. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  5. Is binary HEX?
    By Budgiekarl in forum Tech Board
    Replies: 11
    Last Post: 11-23-2003, 09:02 AM