Skip to search.

Breaking News Visit Yahoo! News for the latest.

×Close this window

  1. Home >
  2. All Categories >
  3. Computers & Internet >
  4. Programming & Design >
  5. Resolved Question
hazen_the_1st hazen_th...
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...

Additional Details

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..

5 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.

5 years ago

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

Best Answer - Chosen by Asker

#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();
}
Asker's Rating:
5 out of 5
Asker's Comment:
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.

Other Answers (2)

  • gjmb1960 by gjmb1960
    Member since:
    July 08, 2006
    Total points:
    32,579 (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
  • modulo_function by modulo_f...
    Member since:
    September 01, 2006
    Total points:
    39,985 (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.

Answers International

Yahoo! does not evaluate or guarantee the accuracy of any Yahoo! Answers content. Click here for the Full Disclaimer.

Help us improve Yahoo! Answers. Send Feedback