Hi guys,

I am new to programming and I am stuck with a homework which is "write a program which calculates the sum of two numbers too long for__long long__ that uses a function". Please help.

I am new to programming and I am stuck with a homework which is "write a program which calculates the sum of two numbers too long for

Last edited on

the way I always work with really long numbers is using arrays, and then just add / subtract / multiply like you did in elementary school. I don't know if it's the most efficient method but it always works :P

for example:

26 + 35 = 61

array1[2] = {2,6}

array2[2] = {3,5}

answer[2] = {0,0}

6+5 = 11 => answer[1] = 1, remember 1

2+3 (+1 remembered) = 6 => answer[0] = 6, remember 0

putting that into a function shouldn't be too difficult :)

for example:

26 + 35 = 61

array1[2] = {2,6}

array2[2] = {3,5}

answer[2] = {0,0}

6+5 = 11 => answer[1] = 1, remember 1

2+3 (+1 remembered) = 6 => answer[0] = 6, remember 0

putting that into a function shouldn't be too difficult :)

Topic archived. No new replies allowed.