# 5x5 array

I need to make a 5x5 array.  And then I have to find the sum of the left diagonal, the sum of the right diagonal, and the sum of the second row.  How do I go about doing this?
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
here is in C:but easily for any other language

int matrix[5][5];
int i_line;
int i_column;
float result;

// 1st diagonal
for (i_line = 0; i_line < 5 ; i_line++)
{
for (i_column = 0; i_column < 5; i_column ++)
{
result = result + matrix[i_line][i_column]
}
}

// 2nd diagonal
for (i_line = 0; i_line < 5 ; i_line++)
{
for (i_column = 5; i_column >0; i_column --)
{
result = result + matrix[i_line][i_column-1]
}
}

// 2nd row
for (i_column = 0;i_column<5; i_column ++)
{
result = result + matrix[2][i_column]
}

here it is!

I'm not sure if the row is inverted with the column, but it's the main idea.

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Commented:
This sounds very much like a homework exercise... EE responders are forbidden to provide direct solutions to questions like this.  However, we can offer advice and suggestions that can lead you to solve the problem yourself.

I'd recommend making a drawing  of 5 small boxes across and 5 deep on a sheet of paper.  Place numbers inside each of the 25 inner squares., then, for each of the 3 sums you want to find, do it manually and observe the steps you took to find the correct square and what you did with the number inside it.  Convert those steps into lines of code in whichever programming language you're using and test it.  Do this for one question at a time.  If you are using subroutines (aka functions, methods, etc depending on the programming language), you can combine all 3 routines into your final version of the program.

HTH,
Lynn
Commented:
Damn! That looks like a 100-level CS class assignment. Summer school huh? If it indeed is for school kid, lemme tell you something. I was like you too...finding the easier way out, but I had to pay the price...now I would like to believe I am self sufficient, at least as far as what I am supposed to do is concerned. I say chap, dont look for easier way out. Good comment Lynn.
Author Commented:
Thank You Weeb0!
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.