# ProgrammingWatch

#1
Question 1:
lplus
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
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
4 years ago
#3
(Original post by FrancescaT7)
Question 1:
lplus
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
4 years ago
#4
(Original post by FrancescaT7)
Question 1:
lplus
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
X

new posts
Back
to top
Latest
My Feed

### Oops, nobody has postedin the last few hours.

Why not re-start the conversation?

see more

### See more of what you like onThe Student Room

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

### University open days

• University of Stirling
Thu, 26 Sep '19
• Heriot-Watt University
Fri, 27 Sep '19
• Royal Holloway, University of London
Sat, 28 Sep '19

### Poll

Join the discussion

#### 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%