This C program is used to check the multiplicability of two matrices. Multiplicability says, if the column if the first matrix matches exactly with the row of the second matrix. For example, Two matrices of order m*n and p*q respectively, can be multiplied if and only if n is equal to p.

Here is the source code of the C program to check multiplicability. The C program is successfully compiled and run on a Linux system. The program output is also shown below.

`#include<stdio.h>`

int main(){

int m, n;

int p, q;

printf("Enter the dimensions of first matrix: ");

scanf("%d%d", &m, &n);

printf("\nEnter the dimensions of second matrix: ");

scanf("%d%d", &p, &q);

if( n != p )

`{`

printf("\nTwo matrices CANNOT be multiplied !!!");

`}`

`else`

printf("\nTwo matrices meet the criteria for Multiplication !!!");

return 0;

`}`

advertisements

$ gcc multiplicability.c -o multiplicability $ ./multiplicability Enter the dimensions of first matrix: 3 3 Enter the dimensions of second matrix: 5 7 Two matrices CANNOT be multiplied !!! $ ./multiplicability Enter the dimensions of first matrix: 3 4 Enter the dimensions of second matrix: 4 5 Two matrices meet the criteria for Multiplication !!!

**Sanfoundry Global Education & Learning Series – 1000 C Programs.**

Here’s the list of Best Reference Books in C Programming, Data Structures and Algorithms.