title: Printing 2D Array using pointers in C
body: <pre><code>#include "stdio.h"
  
  void main(){
   int a[2][2]={1, 2, 3, 4};
   int a[2][2]={1, 2, 3, 4};
   display(a, 2, 2);
   show(a, 2, 2);}
  }
  
  display(int *k, int r, int c){
  int i, j, *z;
   for(i = 0; i &lt; r; i++){
     z = k + i;
     printf("Display\n");
        for(j = 0; j &lt; c; j++){
            printf("%d", *(z + j));
         }
    }
  }
  
  show(int *q, int ro, int co){
  int i, j;
     for(i = 0; i &lt; ro; i++){
       printf("\n");
       for(j = 0; j &lt; co; j++){
         printf("%d", *(q + i*co + j));
       }
     }
  }
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>Display
  12
  23
  Show
  12
  34
  </code></pre>
  
  <p>Why <code>Display()</code> is not showing 1223 while <code>show()</code> gives 1234? Both uses the same logic to display the 2d array. Can any one help please?</p>