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?
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?
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.
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
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.
@PaulS:
Generally, "bigint" or "bignum" refers to numbers that are too large for any native data types -- think 100-digit numbers.