CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 2014
    Posts
    2

    [RESOLVED] HELP : converting a decimal number given by the user to binary using C++

    Write a C++ program that adds three binary numbers of 8-bit
    each. Every number is stored into an array of 8 elements.
    Example:

    Array A
    0 1 2 3 4 5 6 7
    0 1 1 0 1 1 1 0
    +
    Array B
    0 1 2 3 4 5 6 7
    0 1 1 0 1 1 1 0
    +
    Array C
    0 1 2 3 4 5 6 7
    0 1 1 0 1 1 1 0

    Store the result into an array D of 8 elements. Your program
    should show the decimal numbers for every binary number.
    Print screen of 6 answers. This means you should try your
    program six times with different numbers in every run and show
    the printed screen result.
    could you guys help me with this exercise

  2. #2
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,824

    Re: [RESOLVED] HELP : converting a decimal number given by the user to binary using C

    could you guys help me with this exercise
    but this thread is now marked as resolved - so I take it you don't now need guidance?
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  3. #3
    Join Date
    Dec 2014
    Posts
    2

    Re: [RESOLVED] HELP : converting a decimal number given by the user to binary using C

    Quote Originally Posted by 2kaud View Post
    but this thread is now marked as resolved - so I take it you don't now need guidance?
    clicked resolved by mistake and i cant take it down unless i contact the manager. it would be great to guide me

  4. #4
    Join Date
    Jun 2002
    Location
    Stockholm, Sweden
    Posts
    1,641

    Re: [RESOLVED] HELP : converting a decimal number given by the user to binary using C

    Helping you would be a very bad idea, because it appears you did not try on your own to devise a plan how to tackle the problem.

    I can provide some links though:
    http://www.cplusplus.com/doc/tutorial/arrays/
    http://www.cplusplus.com/forum/beginner/143405/
    Nobody cares how it works as long as it works

  5. #5
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,824

    Re: [RESOLVED] HELP : converting a decimal number given by the user to binary using C

    Quote Originally Posted by boushima View Post
    clicked resolved by mistake and i cant take it down unless i contact the manager. it would be great to guide me
    First have a look at http://forums.codeguru.com/showthrea...ork-assignment

    What guidance are you looking for? How far have you got with this assignment? If you post the code you already have we'll be able to provide further help.

    Note when posting code, please use code tags. Go Advanced, select the formatted code and click '#'.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  6. #6
    Join Date
    Jul 2013
    Posts
    576

    Re: [RESOLVED] HELP : converting a decimal number given by the user to binary using C

    Quote Originally Posted by boushima View Post
    could you guys help me with this exercise
    Apply the addition algorithm you learned in first grade only now you use binary numbers instead of decimal numbers. These are different number systems but the addition algorithm is general and works the same regardless.

    To print the decimal equivalent of a binary number you must understand the properties of a positional number system, that is one where each digit position carries a weight.
    Last edited by razzle; December 20th, 2014 at 04:21 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured