Thread: count with carry

  1. #1
    Registered User
    Join Date
    Mar 2009
    Posts
    6

    Question count with carry

    hello
    i have the next define

    #define N 10
    int G1[N], G2[N], G3[N]

    i whant to add G1 an G2 and put it in G3. example:

    G1= 128 G2= 122. when i add 2 and 8 = 10. the carry how i can add this
    to the next count (2 + 2 + 1(carry) ?

    i thought that can be G1[0] + G2[0] = G3[0]
    and next when G3[0] = > 9 then G3[0] = true
    when true than the next count +1 and G3[0] - 10
    but this don't work.

    can someone help me with this ?

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    to assign sum of variable a and b to c you should write

    c = a+b;

    if this does not answers your question - post your code and compilation error
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  3. #3
    Registered User
    Join Date
    Mar 2009
    Posts
    6
    Quote Originally Posted by vart View Post
    to assign sum of variable a and b to c you should write

    c = a+b;

    if this does not answers your question - post your code and compilation error
    thank you that's the answer. it's working now.

    GR
    T&T

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. bintree and count (withouth using template)?
    By cubimongoloid in forum C++ Programming
    Replies: 7
    Last Post: 05-24-2009, 06:22 AM
  2. input question
    By piyush_v in forum C Programming
    Replies: 9
    Last Post: 04-12-2007, 07:09 AM
  3. I'm missing something obvious
    By crash88 in forum C Programming
    Replies: 7
    Last Post: 07-02-2006, 12:51 AM
  4. Help With Stacks
    By penance in forum C Programming
    Replies: 7
    Last Post: 10-09-2005, 02:47 PM
  5. Program Crashing
    By Pressure in forum C Programming
    Replies: 3
    Last Post: 04-18-2005, 10:28 PM