in reply to confused with summing certain elements from an array
There are a number of places to start (actually by asking here and admitting it's homework you've already made a good start).