pradeep | Date: Monday, 08 October 12, 5:54 PM | Message # 1 |
pk
Group: Administrators
Messages: 82
Status: Offline
| Quote #include #include class mat { int a[30][30] , b[30][30], c[30][30]; int i, j,k ,l, m,n; public: void add(void); void sub(void); void mul(void); void div(void); }; void mat:: add() { cout<<"enter matrix size a:\n"; cin>>k>>l; cout<<"Enter matrix size b:\n"; cin>>m>>n; if((k==m)&&(l==n)) { cout<<"\nENTER THE "< for(i=0;i { for(j=0;j cin>>a[i][j]; } cout<<"\nENTER THE "< for(i=0;i { for(j=0;j cin>>b[i][j]; } cout<<"\nSUM OF MATRIX A & B::\n"; for(i=0;i { for(j=0;j c[i][j]=a[i][j]+b[i][j]; } for(i=0;i { for(j=0;j cout< cout<<"\n"; } } else cout<<"\nADDITION IS NOT POSSIBLE::"; } void mat::sub() { cout<<"\nENTER THE DIMENSION OF MATRIX A::\t"; cin>>k>>l; cout<<"\nENTER THE DIMENSION OF MATRIX b::\t"; cin>>m>>n; if((k==m)&&(l==n)) { cout<<"\nENTER THE "< for(i=0;i { for(j=0;j cin>>a[i][j]; } cout<<"\nENTER THE "< for(i=0;i { for(j=0;j cin>>b[i][j]; } cout<<"\nDIFFERENCE OF THE MATRIX A & B::\n"; for(i=0;i { for(j=0;j c[i][j]=a[i][j]-b[i][j]; } for(i=0;i { for(j=0;j cout< cout<<"\n"; } } else cout<<"\nSUBSTRACTION IS NOT POSSIBLE::"; } void mat::mul() { cout<<"\nENTER THE DIMENSION OF MATRIX A::\t"; cin>>k>>l; cout<<"\nENTER THE DIMENSION OF MATRIX b::\t"; cin>>m>>n; if((k==m)&&(l==n)) { cout<<"\nENTER THE " < for(i=0;i { for(j=0;j cin>>a[i][j]; } cout<<"\nENTER THE " < for(i=0;i { for(j=0;j cin>>b[i][j]; } cout<<"\nPROCUCT OF THE MATRIX A & B::\n"; for(i=0;i { for(j=0;j { c[i][j]=a[i][j]*b[i][j]; } } for(i=0;i { for(j=0;j cout< cout<<"\n"; } } else cout<<"\nMULTIPLICATION IS NOT POSSIBLE::"; } void mat::div() { cout<<"\nENTER THE DIMENSION OF MATRIX A::\t"; cin>>k>>l; cout<<"\nENTER THE DIMENSION OF MATRIX b::\t"; cin>>m>>n; if((k==m)&&(l==n)) { cout<<"\nENTER THE " < for(i=0;i { for(j=0;j cin>>a[i][j]; } cout<<"\nENTER THE " < for(i=0;i { for(j=0;j cin>>b[i][j]; } cout<<"\nPROCUCT OF THE MATRIX A & B::\n"; for(i=0;i { for(j=0;j { c[i][j]=0; for(k=0;k c[i][j]=a[i][j]/b[i][j]; } } for(i=0;i { for(j=0;j cout< cout<<"\n"; } } else cout<<"\nDIVISION IS NOT POSSIBLE::"; }
int main() { int c; char ch; mat M; cout<<"\n\t\tMATRIX OPERATION BY Pradeep Kumar\n\n"; cout<<"\n1.ADDITION\n2.SUBSTRACTION\n3.MULTIPLICATION\n4.DIVISION"; cout<<"\nENTER YOUR CHOICE ::\t"; cin>>c; switch© { case 1:M.add(); break; case 2:M.sub(); break; case 3:M.mul(); case 4:M.div(); break; } cout<<"Thanks for Using http://highfile.ucoz.com \n "; getch();
}
|
|
| |