count with carry

This is a discussion on count with carry within the C++ Programming forums, part of the General Programming Boards category; hello i have the next define #define N 10 int G1[N], G2[N], G3[N] i whant to add G1 an G2 ...

  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
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    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
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  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, 07:22 AM
  2. input question
    By piyush_v in forum C Programming
    Replies: 9
    Last Post: 04-12-2007, 08:09 AM
  3. I'm missing something obvious
    By crash88 in forum C Programming
    Replies: 7
    Last Post: 07-02-2006, 01:51 AM
  4. Help With Stacks
    By penance in forum C Programming
    Replies: 7
    Last Post: 10-09-2005, 03:47 PM
  5. Program Crashing
    By Pressure in forum C Programming
    Replies: 3
    Last Post: 04-18-2005, 11:28 PM

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