title: Printing Pattern using Loops
body: <p>I am solving a challenge on hackerrank. It's printing a number in spiral pattern decreasing it's value at each circle completion.</p>
  
  <p>4 4 4 4 4 4 4<br>
     4 3 3 3 3 3 4<br>
     4 3 2 2 2 3 4<br>
     4 3 2 1 2 3 4<br>
     4 3 2 2 2 3 4<br>
     4 3 3 3 3 3 4<br>
     4 4 4 4 4 4 4</p>
  
  <pre><code>//Printing Pattern using Loops
  /* for eg. for n = 4 
    4 4 4 4 4 4 4
    4 3 3 3 3 3 4
    4 3 2 2 2 3 4
    4 3 2 1 2 3 4
    4 3 2 2 2 3 4
    4 3 3 3 3 3 4
    4 4 4 4 4 4 4
   */
   //Author: Arvind Bakshi
   #include &lt;stdio.h&gt;
   #include &lt;string.h&gt;
   #include &lt;math.h&gt;
   #include &lt;stdlib.h&gt;
  
  int main() 
  {
  
  int n,row,col,size;
  scanf("%d", &amp;n);
  // Complete the code to print the pattern.
  size=2*n-1;
    int arr[size][size];
    //n=n+1;
      while(n&gt;0){
          row=0;
          col=0;
          while(col&lt;size){
            arr[row][col] = n;
            col++;
          }
          col=size-1;
          row=0;
          while(row&lt;size){
              arr[row][col]=n;
              row++;
          }
          row = size-1;
          col = size-1;
          while (col &gt;=0) {
            arr[row][col] = n;
            col--;
          }
          col = 0;
          row = size-1;
          while (row &gt;=0) {
            arr[row][col] = n;
            row--;
          }
          n--;
      }
      for(row=0;row&lt;size;row++){
          for(col=0;col&lt;size;col++){
              printf("%d",arr[row][col]);
          }
          printf("\n");
      }
  return 0;
  }
  </code></pre>
  
  <p>Expected output is </p>
  
  <pre><code> 2 2 2 
   2 1 2 
   2 2 2
  </code></pre>
  
  <p>I am getting</p>
  
  <pre><code>111
  101
  111
  </code></pre>
  
  <p>There is numerous code available for it online, I just want to know my mistake, where I am doing wrong. Please don't mark it as a repeat.</p>