title: How would I sum elements in a 2D array?
body: <p>I am trying to to sum values inside a 10 x 10 two dimensional array in <strong>C</strong>. Lets say for example in index[0][0] I have a value of 1. I want to sum up that element and the elements to its immediate right, left, top, and under. So (1 + 0 + 1 ) = 3. </p>
  
  <p>As I move to index[0][1  ] I will now add 4 values given that I know longer am restricted by the corners. for example (0 + 1 + 0 + + 1) = 2 . That is the 0 value at index[0][1 ] and the values in the indexes to its immediate right, left, and bottom given the top is out of its range. I have provided an image blow to help illustrate what I am working with. I tried many things but I am not sure how to mathematically do this in <strong>C language</strong></p>
  
  <p><a href="https://i.stack.imgur.com/N8BGS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/N8BGS.png" alt="enter image description here"></a></p>