Trouble with program converting decimal to binary

This is a discussion on Trouble with program converting decimal to binary within the C Programming forums, part of the General Programming Boards category; Hi everyone! I've just started programming, and I've been trying to write a program that converts a decimal number input ...

  1. #1
    Registered User
    Join Date
    Oct 2011
    Posts
    1

    Trouble with program converting decimal to binary

    Hi everyone!

    I've just started programming, and I've been trying to write a program that converts a decimal number input by the user to a binary number.
    Last edited by simplyxsweet; 10-03-2011 at 10:02 PM.

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Ok, stop and think ... how are numbers stored in the computer? Yep, in binary as groups of high and low voltages that we interpret as 1s and 0s....
    So an integer is just a group of 1s and 0s underneath all that nifty decimalness we use to display it...

    So lets think process for a minute...
    Is there some way to know how many bits are in an int?
    Is there some way to know if the least significant bit of a binary number is a 1 or a 0?
    Is there some way to shift each bit over one place so that each bit in turn appears as the least significant bit?

    (Hint: It's got nothing to do with exponents or powers and it can be done without bitwise operators...)

    Honest this is beyond simple...
    I have a working version here... once we get yours working, I'll show you mine...

  3. #3
    Registered User
    Join Date
    Jan 2009
    Posts
    1,485
    Quote Originally Posted by simplyxsweet View Post
    Below is the code and the errors I've been getting. Thank you!
    Ingenious, how are people suppose to help you now?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. arrays and converting decimal to binary
    By kt1991 in forum C++ Programming
    Replies: 1
    Last Post: 09-12-2011, 02:13 PM
  2. Converting binary string to decimal
    By Sharke in forum C Programming
    Replies: 3
    Last Post: 03-30-2009, 12:18 AM
  3. Converting decimal to binary within a I/O program
    By RandomX in forum C Programming
    Replies: 4
    Last Post: 11-26-2006, 08:25 AM
  4. Converting decimal to binary
    By ubernos in forum C Programming
    Replies: 3
    Last Post: 12-06-2005, 09:09 AM
  5. Converting decimal to binary?
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 04-17-2002, 08:21 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21