FrancescaT7
Badges: 0
Rep:
?
#1
Report Thread starter 4 years ago
#1
Question 1:
lplus
— add two large numbers
Write a function that takes two row arrays of single digits and adds them together,
treating the row arrays as integers. Step-by-step instructions:


Struggling to make a function for this?? HELPPPPPPPPPPPPPPPPPPPP!!!!!!
0
reply
0x2a
Badges: 2
Rep:
?
#2
Report 4 years ago
#2
I don't think the maths forum is the right place to post this.

But, what you want to do is to add the corresponding entries of two arrays. Say you have arrays numbers1() and numbers2() as arrays, then a FOR LOOP can be used to add them entry by entry.
0
reply
tim_123
Badges: 16
Rep:
?
#3
Report 4 years ago
#3
(Original post by FrancescaT7)
Question 1:
lplus
— add two large numbers
Write a function that takes two row arrays of single digits and adds them together,
treating the row arrays as integers. Step-by-step instructions:


Struggling to make a function for this?? HELPPPPPPPPPPPPPPPPPPPP!!!!!!
Think about how the numbers in the array would be stored, so

25 would be [2,5]
And 35 [3,5]

So the item at array1[0] is 2 * 10. And array1[1] is 1 * 5... Think about how you can manipulate these facts to iterate over the array.

One final clue. An array of length 3, will be at largest 999, so array of length 10 9999999999

This is how I understand your question
0
reply
maggiehodgson
Badges: 14
Rep:
?
#4
Report 4 years ago
#4
(Original post by FrancescaT7)
Question 1:
lplus
— add two large numbers
Write a function that takes two row arrays of single digits and adds them together,
treating the row arrays as integers. Step-by-step instructions:


Struggling to make a function for this?? HELPPPPPPPPPPPPPPPPPPPP!!!!!!
I would set up a for loop that counted from the last element of the array to the first (i.e. a step length of -1).
It would add the first digit to a variable preset to zero
The next element (the one to the left you would multiply by 10 and add it to the variable.
So as you step along you multiply by an increasing power of 10 (can use the loop counter for this).

Do the same for the second array into a different integer and then add the two together.
0
reply
X

Quick Reply

Attached files
Write a reply...
Reply
new posts
Back
to top

University open days

  • University of Stirling
    Undergraduate Open Day Undergraduate
    Thu, 26 Sep '19
  • Heriot-Watt University
    Undergraduate Open Day - Scottish Borders Campus Undergraduate
    Fri, 27 Sep '19
  • Royal Holloway, University of London
    Undergraduate open day Undergraduate
    Sat, 28 Sep '19

It is really important for me to be involved in helping make my university better

Strongly disagree (11)
9.17%
Disagree (6)
5%
Neither agree or disagree (40)
33.33%
Agree (46)
38.33%
Strongly Agree (17)
14.17%

Watched Threads

View All
Latest
My Feed

See more of what you like on
The Student Room

You can personalise what you see on TSR. Tell us a little about yourself to get started.

Personalise