Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » Homework HelpRSS Feeds

Program to calculate product or multiplication of two matrices

Posted By: Tyler Thompson     Category: C Programming     Views: 20573

Program to calculate product or multiplication of two matrices

Code for Program to calculate product or multiplication of two matrices in C Programming

/*
MCA-I
NAME : JAY D SONI.
ROLL NO : 154
SUBJECT : FUNDAMENTAL OF PROGRAMING
DATE : 14/12/02
DEFINATION :
*/
#include <stdio.h> #include<conio.h> void main() { int a[3][3],b[3][3],c[3][3]; int i,j,k,l = 1,m = 2; clrscr(); printf("---------------Enter the first matrix A--------------\n"); for(i=0;i<3;i++) { for(j=0;j<3;j++) { gotoxy(l,m); scanf("%d",&a[i][j]); l = l+6; } m = m+1; l=1; } printf("---------------Enter the first matrix B---------------\n"); m = m+1; for(i=0;i<3;i++) { for(j=0;j<3;j++) { gotoxy(l,m); scanf("%d",&b[i][j]); l = l+6; } m = m+1; l = 1; } for(i=0;i<3;i++) { for(j=0;j<3;j++) { c[i][j] = 0; for(k=0;k<3;k++) { c[i][j] += a[i][k] * b[k][j]; } } } printf("\n\n----------The product of two matrix--------------- \n\n" ); for(i=0;i<3;i++) { for(j=0;j<3;j++) { printf("\t%d\t",c[i][j]); if(j==2) { printf("\n\n"); } } } getch(); } /*
*********
OUTPUT
*********

---------------Enter the first matrix A--------------
1 2 3
2 3 4
3 4 5
---------------Enter the first matrix B---------------
1 2 3
3 4 5
2 3 4


----------The product of two matrix---------------

13 19 25

19 28 37

25 37 49

*/
  
Share: 



Tyler Thompson
Tyler Thompson author of Program to calculate product or multiplication of two matrices is from Perth, Australia.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
Dharmendra Gupta from India Comment on: Oct 14
#include<conio.h>
#include<stdio.h>
void main()
{

}

View All Comments