title: How to feed array elements from user (i.e., the console) and how to pass array elements to a function as arguments
body: <p>Here is the original code of Visual C++ which I have been trying to manipulate for more than a day. 
  This is the simplest error-free program which runs correctly.
  What I want to do is insert two functions:  one for taking input from a user, and another for displaying output.</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;iomanip&gt;
  using namespace std;
  
  void main()
  {
      int i, j,r,c;
      int arr[5][5];
      cout&lt;&lt; "enter r and c";
      cin&gt;&gt; i&gt;&gt; j;
  
      for(r=1;r&lt;=i;r++)
      {
          for(c=1;c&lt;=j;c++)
          {
              cout&lt;&lt; "enter elements";
              cin&gt;&gt; arr[r][c];
          }
      }
  
      cout&lt;&lt; " elements are"&lt;&lt; endl;
      for(r=1;r&lt;=i;r++)
      {
          for(c=1;c&lt;=j;c++)
          {
  
              cout&lt;&lt;setw(4) &lt;&lt;arr[r][c];
          }
          cout&lt;&lt; endl&lt;&lt; endl;
      }
  
      cin.ignore();
      getchar();
  }
  </code></pre>
  
  <p>This is what I tried doing but it's giving errors.</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;iomanip&gt;
  using namespace std;
  int input(int i, int j, int arr)
  {   
      int r,c;
      for(r=1;r&lt;=i;r++)
      {
          for(c=1;c&lt;=j;c++)
          {
              cout&lt;&lt; "enter elements";
              cin&gt;&gt; arr[r][c];
  
          }
      }
      return arr[r][c];
  }
  void output(int i, int j, int arr)
  {   
      int r,c;
      for(r=1;r&lt;=i;r++)
      {
          for(c=1;c&lt;=j;c++)
          {
  
              cout&lt;&lt;setw(4) &lt;&lt;arr[r][c];
          }
          cout&lt;&lt; endl&lt;&lt; endl;
      }
  }
  
  void main()
  {
      int i, j,r,c;
      int arr[5][5];
      cout&lt;&lt; "enter r and c";
      cin&gt;&gt; i&gt;&gt; j;
  
      input(i,j,arr);
  
      cout&lt;&lt; " elements are"&lt;&lt; endl;
  
      output(i,j,arr);
      cin.ignore();
      getchar();
  }
  </code></pre>