Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
37 views3 pages

Addition and Multiplication of Two Matrices

Class notes multiplication of matrix

Uploaded by

saadkhan73212
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views3 pages

Addition and Multiplication of Two Matrices

Class notes multiplication of matrix

Uploaded by

saadkhan73212
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

channel link : h ps://www.youtube.

com/c/ComputerScienceAcademy7
video link : h ps://youtu.be/wmQfmNUl13A

/* Prgm 1 : Wap in c++ to read two 3 x 3 matrices and display their sum.
(Addi on of two matrices) */

#include<iostream.h>
#include<conio.h>

void main()
{
clrscr();

int a[3][3], b[3][3], c[3][3];


int i, j, k;

cout<<"Enter 1st 3 x 3 matrix\n";


for(i=0; i<3; i++)
for(j=0; j<3; j++)
cin>>a[i][j];

cout<<"Enter 2nd 3 x 3 matrix\n";


for(i=0; i<3; i++)
for(j=0; j<3; j++)
cin>>b[i][j];

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


for(j =0; j<3; j++)
c[i][j] = a[i][j] + b[i][j] ;

cout<<"Sum matrix\n";
for(i=0; i<3; i++)
{
for(j =0; j<3; j++)
cout<<c[i][j]<<" ";

cout<<"\n";
}
getch();

/* Prgm 2 : Wap in c++ to read two 3 x 3 matrices and display their product
(multplica on of two matrices) */

#include<iostream.h>
#include<conio.h>

void main()
{
clrscr();

int a[3][3], b[3][3], c[3][3];


int i, j, k;

cout<<"Enter 1st 3 x 3 matrix\n";


for(i=0; i<3; i++)
for(j=0; j<3; j++)
cin>>a[i][j];

cout<<"Enter 2nd 3 x 3 matrix\n";


for(i=0; i<3; i++)
for(j=0; j<3; j++)
cin>>b[i][j];

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] = c[i][j] + a[i][k] * b[k][j];
}
cout<<"Product matrix\n";
for(i=0; i<3; i++)
{
for(j =0; j<3; j++)
cout<<c[i][j]<<" ";

cout<<"\n";
}
getch();

You might also like