title: comparing increasing number of columns of array with last column without altering the code
body: <p>Actually i want to compare columns of the 2-D array in the following way 
  for example the array is </p>
  
  <pre><code>A=  [ 1, 1, 1, 1;
  
        0, 0, 1, 0;
  
        0, 1, 0, 0]
  </code></pre>
  
  <p><strong>first step</strong><br>
  I want to compare values of the 1st column [1 0 0] with the values of the 
  last column [1 ,0,0]</p>
  
  <p>for example:  </p>
  
  <pre><code>if (A[0][i]==1 &amp;&amp; A[4][i]=1)
  count++
  </code></pre>
  
  <p>in above code if it finds 1 in first column and 1 in last column on the same row then count will increment   </p>
  
  <p><strong>2nd step</strong><br>
  Now I want to take first two column's values and to compare it with the last column     </p>
  
  <p>for example   </p>
  
  <pre><code>if (A[0][i]==1 &amp;&amp; A[1][i]==1 &amp;&amp; A[4][i]=1)
  count++
  </code></pre>
  
  <p><strong>3rd step :</strong><br>
  now taking first 3 columns and comparing it with last column in same way </p>
  
  <p>but if we need to compare in such a way we need to hard-code the program for example if we increase the size of array to [4][4] then we also need to add "<code>if(A[0][i]==1 &amp;&amp; A[1][i]==1 &amp;&amp; A[2][i]==1  &amp;&amp; A[3][i]==1  &amp;&amp; A[4][i]=1)</code>" if we want to achieve the same comparison. I want to ask is if we change size of array we need to change our software too? i mean we need to add new if conditions ? . if there is anyway to implement the above logic for all size or array without making any changes in the code? and if we don't know the size or array in advance how would we be able to apply such comparison ?</p>