#include
#include
int a[10][10],b[10][10],x[10][10];
void add()
{
int r,c,i,j,n;
cout<<"ENTER THE ORDER OF MATRIX : ";
cin>>n;
r=n;
c=n;
cout<<"ENTER THE ELEMENTS FOR MATRIX 'A' :"<
for(j=0;j
cin>>a[i][j];
}
}
cout<<"ENTER THE ELEMENTS FOR MATRIX 'B' : "<
for(j=0;j
cin>>b[i][j];
}
}
clrscr();
cout<<"MATRIX 'A' IS "<
for(j=0;j
cout< }
cout<
cout<<"MATRIX 'B' IS "<
for(j=0;j
cout< }
cout<
//.....................ADDITION OF MATRIX........................
for(i=0;i
for(j=0;j
x[i][j]=a[i][j]+b[i][j];
}
}
cout<<"THE SUM OF TWO ENTERED MATRIX IS "<
for(j=0;j
cout<
cout<
}
void multiply()
{
int r1,c1,r2,c2,i,j,k;
clrscr();
cout<<"ENTER THE NO.OF ROWS OF MATRIX (A) : ";
cin>>r1;
cout<<"ENTER THE NO.OF COLOUMS OF MATRIX (A) :";
cin>>c1;
cout<<"ENTER THE ELEMENTS FOR MATRIX (A) :"<
for(j=0;j
cin>>a[i][j];
}
}
cout<<"ENTER THE NO.OF ROWS OF MATRIX (B) : ";
cin>>r2;
cout<<"ENTER THE NO.OF COLOUMS OF MATRIX (B) : ";
cin>>c2;
cout<<"ENTER THE ELEMENTS FOR MATRIX (B) :"<
for(j=0;j
cin>>b[i][j];
}
}
clrscr();
cout<<"MATRIX 'A' IS "<
for(j=0;j
cout< }
cout<
cout<<"MATRIX 'B' IS "<
for(j=0;j
cout< }
cout<
if(c1!=r2)
{
cout<<"MULTIPLICATION IS NOT POSSIBLE ";
}
else
{
for(i=0;i
for(j=0;j
x[i][j]=0;
for(k=0;k
x[i][j]=x[i][j]+(a[i][k]*b[k][j]);
}
}
}
}
cout<<"MULTIPLICATION OF TWO MATRIX IS "<
for(j=0;j
cout<
cout<
}
void main()
{
clrscr();
while(1)
{
int ch;
cout<<"
";
cout<<"...ENTER YOUR CHOICE........"<
switch(ch)
{
case 1:
add();
break;
case 2:
multiply();
break;
case 3:
exit(0);
default :
cout<<"INVALID CHOICE !! ENTER CORRECT CHOICE";
}
//getch();
}
}
No comments:
Post a Comment