Advertisement

Multiplication of 2 array

#include<stdio.h>
#include<conio.h>
main()
{
int i,j,k,n,a[11][11],b[11][11],c[11][11]={{0}};
printf("Enter the value of n: \n");
scanf("%d",&n);
printf("Matrix A:\n");
for(i=1;i<=n;++i)
{
 for(j=1;j<=n;++j)
 {
  scanf("%d",&a[i][j]);
 }
}
printf("Matrix B:\n");
for(i=1;i<=n;++i)
{
 for(j=1;j<=n;++j)
 {
  scanf("%d",&b[i][j]);
 }
}
printf("Multiplied matrix\n");
for(i=1;i<=n;++i)
{
 for(j=1;j<=n;++j)
 {
  for(k=1;k<=n;++k)
  {
    c[i][k]+=a[i][j]*b[j][k];
  }
 }
}
for(i=1;i<=n;++i)
{
 for(j=1;j<=n;++j)
 {
 printf("%d ",c[i][j]);
 }
printf("\n");
}
getch();
return 0;
}

No comments:

Post a Comment

Please comment bellow. Share your knowledge