Need help with a simple program

This is a discussion on Need help with a simple program within the C++ Programming forums, part of the General Programming Boards category; Well i got the class c++ programming 2 and i got my first program to write and im stuck.. on ...

Need help with a simple program

Well i got the class c++ programming 2 and i got my first program to write and im stuck.. on the problem here is the problem.. i would appreciate any help i can get. or any ideas of how i can accomplish this. thanks

The sum of each row.
The sum of each column.
The sum of the major diagonal (coordinates that satisfy r=c)
the sum of the minor diagonal (coordinates that satisfy 6-r=c)
The sum of each concentric square (i.e. all points equidistant from the border)

what i got so far. i have the rows and colums adding already i just need some help with the last three. this is what i have so far.

Well i got the class c++ programming 2 and i got my first program to write and im stuck.. on the problem here is the problem.. i would appreciate any help i can get. or any ideas of how i can accomplish this. thanks

The sum of each row.
The sum of each column.
The sum of the major diagonal (coordinates that satisfy r=c)
the sum of the minor diagonal (coordinates that satisfy 6-r=c)
The sum of each concentric square (i.e. all points equidistant from the border)

what i got so far. i have the rows and colums adding already i just need some help with the last three. this is what i have so far.

"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell

What's your question? Have you tried the other three? They follow the same basic procedure as the first two - loop through the values and only sum the ones you want. You just have to figure out the best way to loop through the values. The diagonals should be pretty easy, since you only really need one loop.

For (5), you could start out with some code to sum the whole square (which you almost have, except sum would not be reset to zero after each row). Then add an outer loop to determine where the border starts (for your square the start of the border is going to be either 0, 1, or 2). Then your two inner loops would start at this value, instead of 0 as you are using for parts (1) and (2).