+ 1
Can we add and print the sum of 2 array in a single for loop?
Arrays using for loop
2 RĂ©ponses
+ 4
Yes you can. You loop until the length of the longer array.
And add the values of both arrays together at the same time.
You just need to watch out to only access the array if the loop counter is still smaller than the array length. Because one array could be shorter than the other.
+ 2
Yes.
Aslong as the amount of subarrays is constant we can do that with one loop.