Wednesday, 16 November 2016

Addition of 2 numbers of more than 30 length or more

For example you have to numbers
num1 = 24454543532465465434345465465656546454
num2 = 97867543532465465434345465465656546454

you can not store these in int or long because of range, so how will you do.

Solution-
1. just store both numbers in Array
2. start sum of elements of array from last
3. if any 'carry' then forward it to previous.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.