title: How do i output sum of rows of a 2D array C++
body: <p>EDIT: I'm fairly new to c++. Began working with this language two weeks ago.</p>
  
  <p>Sorry if this have been asked before, but i have searched everywhere on the web on how to sum individual rows in a 2D array and not found the answer that i was looking for.</p>
  
  <p>i need to display the sum of each individual row in a[m][n], but for some reason this only works when my array is 2x2, but if it's 3x3 or bigger, then i get the following output in the terminal:</p>
  
  <pre><code>for intsance, a[3][3]= 
  {1,2,3},   //this is determined by the user
  {1,2,3},
  {1,2,3};
  
  then i get the following output:
  9179942 //address of some sort???
  6       // actual sum. code is working here (yay :D)
  469090925// again something i dont understand
  </code></pre>
  
  <p>This is what i have so far</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  int main(){
  int m,n;
  cout&lt;&lt;"Enter number of rows for array"&lt;&lt;endl;
  cin&gt;&gt;m;
  if (m&gt;10){
      cout&lt;&lt;"More than 10 rows will be too big"&lt;&lt;endl;
      return 1;   
  } 
  cout&lt;&lt;"Enter number of collumns for array"&lt;&lt;endl;
  cin&gt;&gt;n;
  if (n&gt;10){
      cout&lt;&lt;"More than 10 collumns will be too big"&lt;&lt;endl;
      return 1;
  } 
  int a[m][n];
  for(int i=0; i&lt;m;i++){
      cout&lt;&lt;"Enter "&lt;&lt;m&lt;&lt;" values into row "&lt;&lt;i+1&lt;&lt;endl;
      for(int j=0; j&lt;n; j++){
          cout&lt;&lt;"a ["&lt;&lt;i&lt;&lt;"]["&lt;&lt;j&lt;&lt;"]: ";
          cin&gt;&gt;a[i][j];
      }
  }
  cout&lt;&lt;"Array dimensions: "&lt;&lt;m&lt;&lt;"x"&lt;&lt;n&lt;&lt;'\n'&lt;&lt;"resulting array: "&lt;&lt;endl;
  for(int i=0; i&lt;m;i++){
      for(int j=0; j&lt;n; j++){
          cout&lt;&lt;a[i][j]&lt;&lt;"    ";
      }
      cout&lt;&lt;endl;
  }
  int avg[m];
  int el_less_avg;
  for(int i=0; i&lt;m; i++){
      for(int j=0; j&lt;n;j++){
          avg[i]+=a[i][j];
      }
  }cout&lt;&lt;"\n\n";
  for(int i=0; i&lt;m; i++){
  
      cout&lt;&lt;avg[i]&lt;&lt;endl;
  }
  
  return 0;
  }
  </code></pre>