title: How do I set all the diagonals in a matrix equal to zero?
body: <p>I have a problem with my homework that asks me to have the compiler print out a matrix in which all the diagonals are outputted as zero. I also have to pass it to a function. However, I have no idea how to do this..<br>
  Here is my code:</p>
  
  <pre><code>  #include &lt;iostream&gt;
  using namespace std;
  
  int diagonals();
  
  int main()
  {
      //problem 1
      int matrix[3][3];
      for (int i = 1; i &lt;= 3; i++)
      {
          for (int j = 1; j &lt;= 3 ; j++)
          {
              cout &lt;&lt; "Row " &lt;&lt; i &lt;&lt; " column " &lt;&lt; j&lt;&lt; ": ";
              cin &gt;&gt; matrix[i][j];
          }
      }
      for (int i = 1; i &lt;= 3; i++)
      {
          for (int j = 1; j &lt;= 3; j++)
          {
              cout &lt;&lt; matrix[i][j] &lt;&lt; " ";
          }
          cout &lt;&lt; endl;
      }
  
      cout &lt;&lt; "\nReverse of the matrix:" &lt;&lt; endl;
  
      for (int j = 1; j &lt;= 3; j++)
      {
          for (int i = 1; i &lt;= 3; i++)
          {
              cout &lt;&lt; matrix[i][j] &lt;&lt; " ";
          }
          cout &lt;&lt; endl;
      }//end of problem 1
  
      //problem 2
  
      cout &lt;&lt; "Diagonals changed to 0:\n" &lt;&lt; endl;
  
  }
  </code></pre>