title: c++ how to add elements in a column of a 2D array
body: <p>i need help din adding the elements of the 2 column.
  the out of the 2nd column should be 2(bcos 1+1). add the values of each cell(sum =2). how to add the elements of a column.  the loop should move down the column and add the values   </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;iomanip&gt;
  #include &lt;string&gt;
  #include &lt;cctype&gt;
  #include &lt;cstring&gt;
  #include &lt;cstdio&gt;
  #include &lt;cstdlib&gt;
  
  using namespace std;
  
  int main()
  {
    char text[6][6];
      ifstream stream1("c:\\cpptestdata.txt");
  
      if(!stream1)
      {
          cout&lt;&lt;"Cannot read file\n";
  
      }
  
      while(!stream1.eof())
      {
          for(int i=0; i&lt;6; i++)
          {
              for(int j=0; j&lt;6; j++)
              {
                  stream1&gt;&gt;text[i][j];
              }
  
          }
  
      }
  //checking if it has been correctly inserted.
  for(int i=0; i&lt;6; i++)
      {
          for(int j=0; j&lt;6; j++)
          {
              cout&lt;&lt;text[i][j]&lt;&lt;"\t";
  
          }
          cout&lt;&lt;"\n";
  
      }
   cout&lt;&lt;"first two rows:"&lt;&lt;endl;
   int i,j;
   for (i=0; i&lt;2; i++){
   for (j=0; j&lt;6; j++){
              std::cout&lt;&lt;text[i][j]&lt;&lt;"\t"&lt;&lt;' ';
  
              }cout&lt;&lt;endl;
  }
  cout&lt;&lt;"find immediate neighbours of A:"&lt;&lt;endl;
  char largest=text[1][1];
  for(i=0; i&lt;6; i++){
      for(j=1; j&lt;2; j++){
          if(text[i][j]&gt;largest)
               cout&lt;&lt;text[i][0]&lt;&lt;"N"&lt;&lt;"\t";
          else
          cout&lt;&lt;"0";
  
  
  }cout&lt;&lt;endl;
  }
          cout &lt;&lt;" finding k neighbours for A : "&lt;&lt;endl;
  
          for (i=1; i&lt;6; i++){
          int max = text[1][1]-'0';
       for(j = 1; j&lt;2; j++){
              if(max &lt; (text[i][j]-'0')){
                  max = text[i][j]-'0';
                  cout&lt;&lt;max;
              }
              else
                  cout &lt;&lt;"xx";
          }cout&lt;&lt;endl;
  }
  
  
         return 0;
      }
  </code></pre>