title: Finding maximum from matrix : optimise way
body: <p>I want to find out maximum of number from this 5x5 matrix/array of size 25 .
  I am using below trick .But I want to know any other way I can optimize this logic or any other logic is also welcome .Tagging c and cpp to get more coverage for this question .</p>
  
  <pre><code>//Dummy code :
  #include &lt;stdio.h&gt;
  inline int max_val(int x, int y)
  {
      return (x &gt; y)? x : y;
  }
  int main(){
  int src[25] =  {19,26, 34, 48, 50 , 24, 95, 91, 54, 28,47, 45, 48, 68, 24 ,27, 10, 20, 28, 65 ,98, 96, 94, 92, 20};
  /*  just showed as example
  19 26 34 48 50  
  24 95 91 54 28  
  47 45 48 68 24  
  27 10 20 28 65  
  98 96 94 92 20  */
  
  int dst[25]={0} ;//purposefully not initialised as it is dummy code
  int width = 5;
  int* pImage0 = src;
  int* pImage1 = pImage0 + width;
  int* pImage2 = pImage1 + width;
  int* pImage3 = pImage2 + width;
  int* pImage4 = pImage3 + width;
  int BoxMax0,BoxMax1,BoxMax2,BoxMax3,BoxMax4,BoxMax;
  for(int loop =0; loop&lt;25;loop++){
      BoxMax0 = max_val((pImage0[0]),max_val((pImage0[1]),max_val((pImage0[2]),max_val(pImage0[3],pImage0[4]))));
      BoxMax1 = max_val((pImage1[0]),max_val((pImage1[1]),max_val((pImage1[2]),max_val(pImage1[3],pImage1[4]))));
      BoxMax2 = max_val((pImage2[0]),max_val((pImage2[1]),max_val((pImage2[2]),max_val(pImage2[3],pImage2[4]))));
      BoxMax3 = max_val((pImage3[0]),max_val((pImage3[1]),max_val((pImage3[2]),max_val(pImage3[3],pImage3[4]))));
      BoxMax4 = max_val((pImage4[0]),max_val((pImage4[1]),max_val((pImage4[2]),max_val(pImage4[3],pImage4[4]))));
      BoxMax  = max_val(BoxMax0,max_val(BoxMax1,max_val(BoxMax2,max_val(BoxMax3,BoxMax4)));
      pImage0++;
      pImage1++;
      pImage2++;
      pImage3++;
      pImage4++;
      dst[loop] = BoxMax;
  }
  return 0;
  }
  </code></pre>