Multiply two matrices in C++?

Follow
  • Follow publicly
  • Follow privately
  • Unfollow
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...
Update : to modulo_function and Gjmb: TALK LESS AND DO MORE like "Aburva ...show more
Update 2: to modulo_function and Gjmb: TALK LESS AND DO MORE like "Aburva ...show more
Best AnswerAsker's Choice
#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 & comment

5 out of 5
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
  • 1
  • Comment

Other Answers (3)

Rated Highest
  • Rated Highest
  • Oldest
  • Newest
  • gjmb1960 answered 6 years ago
    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
    • Comment
  • Shawn Davis answered 3 months ago
    I tried to copy it but it is not functioning...
    • Rate
    • Comment
  • modulo_function answered 6 years ago
    There's so little difference between C and C++ at this level that I'm surprised at your insistence to get only C++ code.
    • Rate
    • Comment
  • Sign In 

    to add your answer

Who is following this question?

    %
    BEST ANSWERS
    Member Since:
    Points: Points: Level
    Total Answers:
    Points this week:
    Follow
     
    Unfollow
     
    Block
     
    Unblock