I need help adding two arrays of different sizes [i.e. 3005 + 305 = 3310 ]. I am sorry but I do not have any code to post because I am completely lost on how to even go about starting this, so any hints or help on what to do with will be greatly appreciated.
Sorry I probably should have been more specific with my question. The max array size for both arrays is 1000. The numbers in the array are entered by the user so I do not know what they are going to be. The only hint the teacher gave us was that you will need to use at least 2 for loops to add the two arrays together, so that is all I know on what has to be done in order to add 2 arrays of different sizes together.
>>so I do not know what they are going to be.
Count them as the user enters the numbers. Each time you enter a number increment the counter by 1.
>>you will need to use at least 2 for loops to add the two arrays together,
If array A contains 10 numbers and array B contains 7 numbers, then the first loop counts from 0 to 7 and the second loop only counts from 7 to 10 to get the numbers that are in A but not in B.
I think your teacher needs to further clarify the assignment. By your example, I see it as
arr1 3 0 0 5
arr2 0 3 0 5
sol 3 3 1 0
where adding the two fives in the lowest position represent adding the one's column of decimal values - carrying the ten to the next position.
This is not normal matrix math, this is simulation decimal arithmetic. But, I might be misinterpreting what's being asked of you.
Either way, I don't see two for loops being needed.
In your example just fill in the missing elements with 0 to make both arrays the same size, then do like vmanes mentioned, assuming that's what his teacher wants. And that would explain the need for two loops.
vmanes your example is accurate in what we are trying to accomplish. The using two for loops was only a suggestion by the teacher of how it could be done. So you are saying what we are trying to do is 'simulation decimal arithmetic', will I be able to google this and find examples that may help me in generating my own code that I can then post for help?
Better yet. Get out a piece of paper and a pencil (I know, that's so 20th Century). Try to describe/define what you think you need to do to solve this. What data do you need to get from user, how do you store it? Then, what steps would you do to solve it manually - step by step? Finally, how do you display the result?
This assignment should be applying recent material from your class - look to your notes and the text.
When you start coding, take it one part at a time. Get your data storage allocated. Then input into it. Get that working before going to next step.