• ## Discover

1. Home >
2. All Categories >
3. Computers & Internet >
4. Programming & Design >
5. Resolved Question
Member since:
April 12, 2008
Total points:
148 (Level 1)

## Resolved Question

Show me another »

# Multiply two matrices in C++?

I have to multiply two 2X2 matrices in C++. Note that I need C++ CODE for this program.. Those who know it in C, don't reply because I dont need C codes..
Only C++ codes...

to modulo_function and Gjmb: TALK LESS AND DO MORE like "Aburva D", understand ?
To Aburva D: Thank u vry much.. Im going to select ur reply as the best answer..

6 years ago

to modulo_function and Gjmb: TALK LESS AND DO MORE like "Aburva D", understand ?
To Aburva D: Thank u vry much.. Im going to select ur reply as the best answer.

6 years ago

by Aburva D
Member since:
May 04, 2008
Total points:
371 (Level 2)

#include<stdio.h>
#include<iostream.h>
#include<conio.h>
int a[10][10];int b[10][10];int c[10][10];
void main()
{
int i,j,k,l;
clrscr();
cout<<"Enter the value of the matrix a:";
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
cin>>a[i][j];
}
}
cout<<"\n Enter the value of the matrix b:";
or(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
cin>>b[i][j];
}
}

cout<<"\n The multiplied value is:";
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
c[i][j]=0;
for(k=0;k<2;k++)
{
c[i][j]=c[i][j]+(a[i][k]*b[k][j]);
}
}
}
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
cout<<c[i][j];
}
cout<<"\n"
}

getch();
}
How Can I thank u..? I had to submit the program to my teacher by 2 hours and your's one is exactly what I wanted... Thank u.. u deserve 10 points

There are currently no comments for this question.

• by gjmb1960
Member since:
July 08, 2006
Total points:
32,609 (Level 7)
if you know it in c, then to transform it into c++ you can make a class and one static method in it with the c code.
• 1 person rated this as good
• Member since:
September 01, 2006
Total points:
43,190 (Level 7)
There's so little difference between C and C++ at this level that I'm surprised at your insistence to get only C++ code.
• Member since:
January 31, 2014
Total points:
101 (Level 1)
I tried to copy it but it is not functioning...