Advertisement Remove all ads

# Write a Program to Multiply Two Matrices After Checking Compatibility. - Structured Programming Approach

Advertisement Remove all ads
Advertisement Remove all ads

Write a program to multiply two matrices after checking compatibility.

Advertisement Remove all ads

#### Solution

#include
#include
void main(){
int a[10][10], b[10][10],mul[10][10];
int i,j,c,r,n;
clrscr();

printf("Enter the number of columns:");
scanf("%d",&c);printf("Enter the number of rows:");
scanf("%d",&r);printf("Enter the elements of first matrix:");
for(i=0;i<c;i++)
{
for(j=0;j<r;j++)
{
scanf("%d",&a[i][j]);}}
printf("Enter the elements of second matrix:");
for(i=0;i<c;i++)
{
for(j=0;j<r;j++)
{
scanf("%d",&b[i][j]);
}
}
printf("\nThe Ma
trix after multiplication is:\n");
for(i=0;i<c;i++)
{
for(j=0;j<r;j++)
{
mul[i][j] = a[i][j]*b[i][j];
}
}
for(i=0;i<c;i++)
{
for(j=0;j<r;j++)
{
printf("%d\t",mul[i][j]);
}
printf("\n");
}
getch();

}
Output:Enter the number of columns: 3
Enter the number of rows: 3
Enter the elements of first matrix: 1 2 3 4 5 6 7 8 9
Enter the elements of second matrix: 1 2 3 4 5 6 7 8 9
The Matrix after multiplication is:1    4     916  25  3649  64  81
Concept: Array
Is there an error in this question or solution?
Advertisement Remove all ads

#### APPEARS IN

Advertisement Remove all ads
Share
Notifications

View all notifications

Forgot password?