Basic Programs
If Else based Programs
Loop Based Programs
Array Based Programs
String Programs
Function Programs
Pointers Programs
Structure & File Handling Programs
Data Structure Programs
Array based programs
Matrix multiplication Program
#include<stdio.h>
#include<conio.h>
void main()
{
int rows,cols,i,j,k,a[10][10],b[10][10],c[10][10];
printf("Enter the number of rows and columns \n");
scanf("%d%d", &rows, &cols);
printf("Enter the elements of first matrix\n");
for (i = 0; i< rows; i++)
{
for (j= 0; j < cols; j++)
{
scanf("%d", &a[i][j]);
}
}
printf("Enter the elements of second matrix\n");
for (i = 0; i< rows; i++)
{
for (j= 0; j < cols; j++)
{
scanf("%d", &b[i][j]);
}
}
for (i = 0; i< rows; i++)
{
for (j= 0; j < cols; j++)
{ c[i][j]=0;
for(k=0;k<cols;k++)
{
c[i][j]=c[i][j]+a[i][k]*b[k][j];
}
}
}
printf("product of two matrices is as below\n");
for (i = 0; i< rows; i++)
{
for (j= 0; j < cols; j++)
{
printf("%d ", c[i][j]);
}
printf("\n");
}
}
Output of the above program is as following.
Matrix Addition Program
Video/ C Introduction
Watch video in full size