Thread: c++ : binary addition

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    The main 8 part of the "if/else if" have to set the correct value for "carry".

    I suggest working on adding without using the input code till you get adding to partly work.

    Code:
        int arr[5] = {1,0,0,0,0}; // Binary 00001
        int arr1[5] = {1,1,0,0,0}; // Binary 00011
    Code:
        cout<<" arr = "<<arr[4]<<arr[3]<<arr[2]<<arr[1]<<arr[0]<<endl;
        cout<<" arr1 = "<<arr1[4]<<arr1[3]<<arr1[2]<<arr1[1]<<arr1[0]<<endl;
    Code:
        cout<<" sum = "<<sum[5]<<sum[4]<<sum[3]<<sum[2]<<sum[1]<<sum[0]<<endl;
    FYI: You last "for" loop is NOT inside the main function; I suugest trying to get code to compile without errors before posting it.
    Or, post the errors and warnings if it has them.
    Last edited by stahta01; 05-19-2011 at 08:25 AM.

  2. #2
    Registered User
    Join Date
    May 2011
    Posts
    16
    plzz help me ((

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 10-08-2010, 01:30 PM
  2. need some help with binary addition.
    By InvariantLoop in forum C++ Programming
    Replies: 21
    Last Post: 01-27-2005, 06:52 AM
  3. New addition
    By RoD in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 11-06-2004, 08:41 PM
  4. saturated binary/hex addition
    By revelation437 in forum A Brief History of Cprogramming.com
    Replies: 13
    Last Post: 03-09-2004, 06:11 PM
  5. Binary tree addition
    By crag2804 in forum C Programming
    Replies: 2
    Last Post: 09-30-2002, 07:48 AM