**Statement of C Program:**This Program accepts two Matrices of different or same order and Find the product of these Matrices and prints the Product Matrix:

**Condition:**The Column of First Matrix must be Equal to the Row of the Second Matrix.

#include<stdio.h>

#include<conio.h>

void main()

{

int Matrix A[9][9] , MatrixB[9][9] , Matrixsproduct [9][9] ;

int n , i , j , k; /*

**'i' used for rows and 'j' used for columns***/int Row1 , Row2 , Column1 , Column2;

clrscr();

printf(" Enter the order of Matrix A\n");scanf("%d * %d " , &Row1 , &Column1);

printf(" Enter the order of Matrix B\n");

scanf("%d * %d " , &Row2 , &Column2);

**if**(Column1 == Row2)

{

**printf(" Enter the elements of Matrix A\n");**

for(i=0 ; i<Row1 ; i++)

{

for(j=0 ; j<Column1 ; j++)

{

scanf("%d" , &Matrix A[i][j] );

}

}

**printf(" Enter the elements of Matrix B\n");**

for(i=0 ; i<Row2 ; i++)

{

for(j=0 ; j<Column2 ; j++)

{

scanf("%d" , &Matrix B[i][j] );

}

}

**/* Product of two Matrices */**

for(i=0 ; i<Row1 ; i++)

{

for(j=0 ; j<Column2 ; j++)

{

Matrixproduct[i][j] = 0 ;

for(k=0 ; k<Row2 ; k++)

{

Matrixproduct[i][j] = Matrixproduct[i][j] + ( Matrix A[i][k] * Matrix B[k][j] );

}

}

}

**printf(" Product Matrix\n");**

for(i=0 ; i< Row1 ; i++)

{

for(j=0 ;j< Column2;j++)

{

printf("%d" , Matrixproduct[i][j] );

}

printf("\n");

}

} /*

**End of if***/**else**

{

printf(" Invalid order so Multiplication not possible\n");

} /*

**End of main()***/ Output:

Enter the order of Matrix A

2 * 2

Enter the order of MatrixB

2 * 2

Enter the elements of Matrix A

1

2

3

4

Enter the elements of Matrix B

5

6

7

8

Product Matrix

19 22

43 50

**That's All**

Appreciation for nice Updates, I found something new and folks can get useful info about BEST ONLINE TRAINING

ReplyDeletewhat is the k loop doing there.

ReplyDeleteThe "k" loop is used for to multiple the two matrix and print the sum of the two matrix.

DeleteIts showing error program

ReplyDeletethat's too long ! program.

ReplyDeleteIs there any other logic for multiplication. This logic is somewhat comfusing.

ReplyDeletedo '*' symbol is allowed in scanf() function ?

ReplyDeletefor best explanation visit cncreate.blogspot.in/2014/05/c-programming-language-multiplication.html

ReplyDeleteIts a nice post and sudipta its not at all too long. The logic of the program is in */Product of Two Matrices /* which is quite small..

ReplyDeleteSee this : Best c compiler for windows

super fantastic blog to learn matrix operations easily

ReplyDelete

ReplyDeleteThank you for sharing this Useful Information !!

LINUX INTERVIEW QUESTIONS

Linux FTP vsftpd Interview Questions

SSH Interview Questions

Apache Interview Questions

Nagios Interview questions

IPTABLES Interview Questions

Ldap Server Interview Questions

LVM Interview questions

Sendmail Server Interview Questions

Read more at Linux Troubleshooting

Really very informative and useful for everyone.

ReplyDeletec language training

IT"S show so much of error

ReplyDeletefor more result you can visit http://www.tutorialworld.in

ReplyDeleteWow amazing i saw the article with execution models you had posted. It was such informative. Really its a wonderful article. Thank you for sharing and please keep update like this type of article because i want to learn more relevant to this topic.

ReplyDeleteBest Linux training in Noida

Linux Training Institute in Noida

Shell Scripting Training Institute in Noida