title: how do multiply different sized matrices in c
body: <p>I'm looking for a way to multiply a 2x1 and a 2x2 matrix together but my code doesn't work almost every time and even when it does work I have to put the numbers into the code. It doesn't wok if i try asking for the numbers when I run the code</p>
  
  <p>Here is my code so far:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  int main(void)  
  {  
    unsigned int a[1][2],b[2][2],c[2][1], i=0, j=0, k=0;  
    printf("-=Program to Multiply two Matrices=-");  
  
  
  //--------------------------------------------------------------------  
  
   printf("\nEnter the values of Matrix A: \n");  
  
    for(i=0;i&lt;1;i++)  
      {  
        for(j=0;j&lt;2;j++)  
          {  
           // printf("\n"); 
            scanf("%d",&amp;a[i][j]);  
          }  
       }  
     printf("\nMatrix A: ");  
     for(i=0;i&lt;1;i++)  
      {  
        printf("\n");  
        for(j=0;j&lt;2;j++)  
          {  
            printf(" ");  
            printf("%d",a[i][j]);  
          }  
       }  
  //----------------------------------------------------  
  
  printf("\nEnter the values of Matrix B: \n");  
    for(i=0;i&lt;2;i++)  
      {  
        for(j=0;j&lt;2;j++)  
          {  
           // printf("\n");  
            scanf("%d",&amp;b[i][j]);  
          }  
       }  
     printf("\nMatrix B: ");  
     for(i=0;i&lt;2;i++)  
      {  
        printf("\n");  
        for(j=0;j&lt;2;j++)  
          {  
            printf(" ");  
            printf("%d",b[i][j]);  
          }  
       }  
  
  //--------------------------------------------------------  
  
    printf("\n\nMultiplication of matrices A and B is : \n\n");  
    for(i=0;i&lt;2;i++)  
     {  
       for(j=0;j&lt;2;j++)  
         {  
            c[i][j]=0;  
            for(k=0;k&lt;1;k++)  
              {  
          c[i][j]=c[i][j]+(a[i][k]*b[k][j]);  
              }  
         }  
     }  
    printf("\nMatrix C (Resultant Matrix): ");  
      for(i=0;i&lt;2;i++)  
      {  
        printf("\n");  
        for(j=0;j&lt;1;j++)  
          {  
            printf(" ");  
            printf("%d",c[i][j]);  
          }  
       }  
  printf("\n");  
    return 0;  
  }  
  </code></pre>