title: Display 2D array using pointers and function in c
body: <p>Respected members of stackoverflow,
                       Am a complete armature to c program,I want to access the element of the matrix using pointers.like i want to print the elements of the matrix using point.I have attached the code along with the incorrect output.please help me .thank you</p>
  
  <pre><code>`
  #include&lt;stdio.h&gt;
  #include&lt;conio.h&gt;
  
  void print(int **arr, int m, int n)
  {
      int i, j;
      for (i = 0; i &lt; m; i++)
      {
        for (j = 0; j &lt; n; j++)
        {
      printf("%d ",*(arr+i*n+j));                   //print the elements of the matrix
      //printf("%d ", *((arr+i*n) + j));
        }
        printf("\n");
      }
  }
  
  
  int main()
  {
      int arr[20][20],m,n,c,d;
      clrscr();
      printf("row=\n");
      scanf("%d",&amp;m);
      printf("col=\n");
      scanf("%d",&amp;n);
      for(c=0;c&lt;m;c++)
      {
       for(d=0;d&lt;n;d++)
        {
         scanf("%d",&amp;arr[c][d]);
        }
      }
      for(c=0;c&lt;m;c++)                      //print the matrix without function calling
      {
       for(d=0;d&lt;n;d++)
       {
       printf("%d ",arr[c][d]);
       }
       printf("\n");
      }
      print((int **)arr, m, n);            //print the matrix using function calling
      getch();
      return 0;
  }` 
  </code></pre>
  
  <p>above code produce the output shown  below</p>
  
  <pre><code>row=
  2
  col=
  3
  //elements of the matrix
  2
  3
  4
  5
  6
  7
  //print without using function
  2 3 4
  5 6 7
  //print using function"print(int **a,int m,int n)"
  2 3 4
  0 0 0
  </code></pre>
  
  <p>when using function am not getting  the exact matrix value.
  <strong>NOTE:print(int **a,int m,int n) should be used.</strong></p>