I am attempting to find what would be described as the best method for the following array named arr to correctly add all the elements together.
7 8 0 1
2 4 7 9
6 5 3 2
Would this be a suitable method and why? I am still trying to understand how for-loops work so any suggestions would be helpful. What am I looking for to ensure that all the elements are correctly added together.
I know a storage variable will be needed, which is sum.
Have you tested your method? If so, what was the result? Have you also tested the code for 2D arrays that are not square?
There are three kinds of actuaries: those who can count, and those who can't.
posted 5 days ago
True, I have wondered if the arrays were of a varying length
I have also tried this method
The problem with the first one is that it won't compile, which is fine for now as I am trying to figure out which/what method would be best to approach this issue.
The potential problem with this method I see is that it is printing re twice, which doesn't exactly tell me if its printing out the column. The numbers that appear are 3 rows with 4 columns from the first post.