Code:
#include<stdio.h> 
#include<conio.h> 
void main() 
{ 
int a[20][20],b[20][20],c[20][20],i,j,k,m,n,p,q; 
clrscr(); 
printf("enter no. of rows and column for 1st matrix\n"); 
printf("no.of rows\n"); 
scanf("%d",&m); 
printf("no. of columns"); 
scanf("%d",&n); 
printf("\nenter no. of rows and columns for 2nd matrix"); 
printf("\nno. of rows"); 
scanf("%d",&p); 
printf("\nno. of columns"); 
scanf("%d",&q); 
if(n==p) 
{ 
   printf("enter elements for matrix A"); 
   for(i=0;i<m;i++) 
  { 
     for(j=0;j<n;j++) 
       scanf("%d",&a[i][j]); 
   } 
   printf("enter elements for matrix B"); 
   for(i=0;i<p;i++) 
  { 
     for(j=0;j<q;j++) 
        scanf("%d",&b[i][j]); 
   } 
    printf("\nMATRIX A:\n"); 
                           for(i=0;i<m;i++) 
  { 
     for(j=0;j<n;j++) 
     { 
         printf("%d",a[i][j]); 
         printf("\t"); 
      }   
      printf("\n"); 
    } 
    printf("\nMATRIX B:\n"); 
    for(i=0;i<p;i++) 
    { 
    for(j=0;j<q;j++) 
   { 
      printf("%d",b[i][j]); 
      printf("\t"); 
    } 
    printf("\n"); 
} 
printf("\n"); 
printf("MULTIPLICATION :\n"); 
for(i=0;i<m;i++) 
{ 
    for(j=0;j<q;j++) 
   { 
       for(k=0;k<p;k++) 
      { 
           c[i][j]=c[i][j]+(a[i][k]*b[k][j]); 
       }    printf("%d",c[i][j]); 
    c[i][j]=0; 
    printf("\t"); 
  } 
  printf("\n"); 
 } 
} 
else 
    printf("multiplication is not possible"); 
getch(); 
}