write the psuedocode for a computer program that computes the sum of the numbers on the diagonal of a 10 x 10 integer array named numbers.
Here is what i got but i'm not sure:

``````int SIZE = 10;
int [ ] numbers = new int[SIZE] [SIZE];
for (int I = 0; I < numbers.length; I++)
numbers [ I ] = sum [I];
print sum;
``````
3
Contributors
3
Replies
15
Views
4 Years
Discussion Span
Last Post by JamesCherrill

ok. First there are several thing I would like to point out. When you are summing you set the number at I equal to the sum at I. What you want to do is create another variable outside of the loop, and add the number at the I value to the sum variable. Second you will want to take a look at 2D arrays also to traverse the 2D array you will need a nested for loop (a for loop inside of the for loop) and make sure you don't use the same counter. You will also want to print out the sum after your outer for loop has completed.

I hope this helps

Ok thanks a lot

To sum a diagonal you just need one loop and one counter. You don't want nested loops

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.