I am using this function with my ADT Natural number in large precision

(My DT is

Code:

struct NatNo{ unsigned n; //number of digits
unsigned V[30]; // array of digits in order of introduction ( starting from 0)
}

)

Code:

void add(NatNo a, NatNo b, NatNo &sum)
{
unsigned i;
unsigned maxlength= a.n>b.n? a.n: b.n;
init(sum, maxlenght); /* initializes sum with maxlength elements of 0 (s.n=maxlength and the array(s.V) with zero values ) */
for(i=a.n;i<maxlength;i++)
a.V[i]=0;
for(i=b.n;i<maxlength;i++)
b.V[i]=0;
for(i=maxlength-1;i>=0;i--);
{
sum.V[i+1] += (a.V[i] + b.V[i]) % 10; /* the sum will have an additional
digit(pozition 0) for overflow */
sum.V[i] += (a.V[i] + b.V[i]) / 10; // transportation
}
}