Thread: Add two big integer numbers without use of arrays

  1. #1
    Registered User
    Join Date
    Dec 2014
    Posts
    1

    Post Add two big integer numbers without use of arrays

    i'm having difficulty with a problem, i need to add two big numbers suchas 54646774456776 and another one 445556777554 and it would print the result. how can i approach this problem without the use of arrays?

  2. #2
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    Well ... this is a homework exercise (only a homework exercise would impose an unrealistic constraint such as "do this without arrays" in order to force you to think of alternatives) so you're not going to get solutions here.

    I'll give you a hint though. Consider if some other data structure can be used to represent a set with a variable number of elements.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  3. #3
    TEIAM - problem solved
    Join Date
    Apr 2012
    Location
    Melbourne Australia
    Posts
    1,907
    My advice - Do it by hand.

    Take note of the process you are doing.

    Can you do something simple such as c=15+16 using arrays? You know the answer needs to be 31.
    Code:
    int a[]={1,6};
    int b[]={1,5};
    int c[3]={0};  //Initialized to {0,0,0} if this confuses you...
    Fact - Beethoven wrote his first symphony in C

  4. #4
    Registered User
    Join Date
    Sep 2014
    Location
    SE Washington State
    Posts
    65
    I may be confused but can't you just:

    int bigint1;
    int bigint2;
    int sum =0;
    print"enter first big int"
    get bigint1
    print"enter second big int"
    get bigint2
    sum = bigint1 + bigint2
    print"sum"

    granted there is no code there but the concept for adding two big integers is there.

    Now if you want to concatenate the two numbers it could be done with a simple print command without spaces between them.

  5. #5
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    @PaulS:
    Generally, "bigint" or "bignum" refers to numbers that are too large for any native data types -- think 100-digit numbers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Integer remainder for negative numbers
    By StanS in forum C Programming
    Replies: 4
    Last Post: 11-23-2011, 05:41 PM
  2. Replies: 3
    Last Post: 11-21-2011, 05:03 AM
  3. Multiplying Huge numbers in integer arrays
    By invierno in forum C Programming
    Replies: 5
    Last Post: 04-11-2009, 08:40 PM
  4. Stripping Float numbers of the integer
    By Bobnine in forum C Programming
    Replies: 2
    Last Post: 09-17-2008, 01:09 AM
  5. converting a string of numbers into an integer value -How?
    By v3ct0r_sect0r in forum C++ Programming
    Replies: 1
    Last Post: 04-25-2004, 07:58 AM

Tags for this Thread