title: Matrix Multiplication through function in C
body: <p>I just want to create a program that can solve the Matrix multiplication. I can solve this problem with only using main function but I did not solve this in using different function. In my code 1st I make 4 function. The 1st function will give the number of rows and column form user. 2nd function will collect the values of matrix. 3rd function will print the value of function. 4th function will  show the result of multiplication of the matrix. Here is my code and the errors that compiler give me for this code.</p>
  <pre><code>#include &lt;stdio.h&gt;
  void inputRowColForGun(int Ar, int Ac, int Br, int Bc)
  {
   do
   {
       printf(&quot;Enter the value of row &amp; column of A: &quot;);
       scanf(&quot;%d %d&quot;, &amp;Ar, &amp;Ac);
       printf(&quot;\n&quot;);
       printf(&quot;Enter the value of row &amp; column of B: &quot;);
       scanf(&quot;%d %d&quot;, &amp;Br, &amp;Bc);
       printf(&quot;\n&quot;);
       if (Ac == Br)
       {
           break;
       }
       printf(&quot;Error ! Your A matrix column and B matrix row should be same.\n&quot;);
   } while (Ac != Br);
  }
  
  void inputmat(int Ar, int Ac, int A[Ar][Ac])
  {
   for (int a = 0; a &lt; Ar; a++)
   {
       for (int b = 0; b &lt; Ac; b++)
       {
           printf(&quot;Enter the value of Mat%d%d : &quot;, a + 1, b + 1);
           scanf(&quot;%d&quot;, &amp;A[a][b]);
       }
       printf(&quot;\n&quot;);
   }
  }
  
  void printmat(int r, int c, int A[r][c])
  {
   printf(&quot;\n\nMatrix=\n&quot;);
   for (int e = 0; e &lt; r; e++)
   {
       for (int f = 0; f &lt; c; f++)
       {
           printf(&quot; %d&quot;, A[e][f]);
       }
       printf(&quot;\n&quot;);
   }
  }
  
  void resultOfGun(int A[Ar][Ac], int B[Br][Bc], int Ar, int Ac, int Br, int Bc)
  {
   printf(&quot;\nA*B = \n&quot;);
   for (int i = 0; i &lt; Ar; i++)
   {
       for (int j = 0; j &lt; Bc; j++)
       {
           int R = 0;
           for (int k = 0; k &lt; Ac; k++)
           {
               R = R + A[i][k] * B[k][j];
           }
           printf(&quot; %d &quot;, R);
       }
       printf(&quot;\n&quot;);
   }
  }
  
  void main()
  {
   int Ar, Ac, Br, Bc;
   printf(&quot;=== Matrix's Multiplication === \n\n\n&quot;);
   inputRowColForGun(Ar, Ac, Br, Bc);
   int A[Ar][Ac], B[Br][Bc];
   inputmat(A, Ar, Ac);
   inputmat(B, Br, Bc);
   printmat(A, Ar, Ac);
   printmat(B, Br, Bc);
   resultOfGun(A, B, Ar, Ac, Br, Bc);
  }
  </code></pre>
  <pre><code>Errors:
  
  PS D:\Github\Learn c&gt; cd &quot;d:\Github\Learn c\&quot; ; if ($?) { gcc tempCodeRunnerFile.c -o tempCodeRunnerFile } ; if ($?) { .\tempCodeRunnerFile 
  }
  tempCodeRunnerFile.c:47:24: error: 'Ar' undeclared here (not in a function)
   void resultOfGun(int A[Ar][Ac], int B[Br][Bc], int Ar, int Ac, int Br, int Bc)
                          ^~
  tempCodeRunnerFile.c:47:28: error: 'Ac' undeclared here (not in a function)
   void resultOfGun(int A[Ar][Ac], int B[Br][Bc], int Ar, int Ac, int Br, int Bc)
                              ^~
  tempCodeRunnerFile.c:47:39: error: 'Br' undeclared here (not in a function)
   void resultOfGun(int A[Ar][Ac], int B[Br][Bc], int Ar, int Ac, int Br, int Bc)
                                         ^~
  tempCodeRunnerFile.c:47:43: error: 'Bc' undeclared here (not in a function)
   void resultOfGun(int A[Ar][Ac], int B[Br][Bc], int Ar, int Ac, int Br, int Bc)
                                             ^~
  tempCodeRunnerFile.c: In function 'main':
  tempCodeRunnerFile.c:71:14: warning: passing argument 1 of 'inputmat' makes integer from pointer without a cast [-Wint-conversion]
       inputmat(A, Ar, Ac);
                ^
  tempCodeRunnerFile.c:21:19: note: expected 'int' but argument is of type 'int (*)[(sizetype)(Ac)]'
   void inputmat(int Ar, int Ac, int A[Ar][Ac])
                 ~~~~^~
  tempCodeRunnerFile.c:71:21: warning: passing argument 3 of 'inputmat' makes pointer from integer without a cast [-Wint-conversion]
       inputmat(A, Ar, Ac);
                       ^~
  tempCodeRunnerFile.c:21:35: note: expected 'int (*)[(sizetype)(Ac)]' but argument is of type 'int'
   void inputmat(int Ar, int Ac, int A[Ar][Ac])
                                 ~~~~^~~~~~~~~
  tempCodeRunnerFile.c:72:14: warning: passing argument 1 of 'inputmat' makes integer from pointer without a cast [-Wint-conversion]
       inputmat(B, Br, Bc);
                ^
  tempCodeRunnerFile.c:21:19: note: expected 'int' but argument is of type 'int (*)[(sizetype)(Bc)]'
   void inputmat(int Ar, int Ac, int A[Ar][Ac])
                 ~~~~^~
  tempCodeRunnerFile.c:72:21: warning: passing argument 3 of 'inputmat' makes pointer from integer without a cast [-Wint-conversion]
       inputmat(B, Br, Bc);
                       ^~
  tempCodeRunnerFile.c:21:35: note: expected 'int (*)[(sizetype)(Ac)]' but argument is of type 'int'
   void inputmat(int Ar, int Ac, int A[Ar][Ac])
                                 ~~~~^~~~~~~~~
  tempCodeRunnerFile.c:73:14: warning: passing argument 1 of 'printmat' makes integer from pointer without a cast [-Wint-conversion]
       printmat(A, Ar, Ac);
                ^
  tempCodeRunnerFile.c:34:19: note: expected 'int' but argument is of type 'int (*)[(sizetype)(Ac)]'
   void printmat(int r, int c, int A[r][c])
                 ~~~~^
  tempCodeRunnerFile.c:73:21: warning: passing argument 3 of 'printmat' makes pointer from integer without a cast [-Wint-conversion]
       printmat(A, Ar, Ac);
                       ^~
  tempCodeRunnerFile.c:34:33: note: expected 'int (*)[(sizetype)(c)]' but argument is of type 'int'
   void printmat(int r, int c, int A[r][c])
                               ~~~~^~~~~~~
  tempCodeRunnerFile.c:74:14: warning: passing argument 1 of 'printmat' makes integer from pointer without a cast [-Wint-conversion]
       printmat(B, Br, Bc);
                ^
  tempCodeRunnerFile.c:34:19: note: expected 'int' but argument is of type 'int (*)[(sizetype)(Bc)]'
   void printmat(int r, int c, int A[r][c])
                 ~~~~^
  tempCodeRunnerFile.c:74:21: warning: passing argument 3 of 'printmat' makes pointer from integer without a cast [-Wint-conversion]
       printmat(B, Br, Bc);
                       ^~
  tempCodeRunnerFile.c:34:33: note: expected 'int (*)[(sizetype)(c)]' but argument is of type 'int'
   void printmat(int r, int c, int A[r][c])
                               ~~~~^~~~~~~
  tempCodeRunnerFile.c:75:17: error: type of formal parameter 1 is incomplete
       resultOfGun(A, B, Ar, Ac, Br, Bc);
                   ^
  tempCodeRunnerFile.c:75:20: error: type of formal parameter 2 is incomplete
       resultOfGun(A, B, Ar, Ac, Br, Bc);
                      ^
  PS D:\Github\Learn c&gt; 
  
  </code></pre>
  <p>please solve this problem. Thank you very much</p>