skip to main
|
skip to sidebar
C++ Programs
Based on cusat cs 3rd sem 2009 lab cycle
Thursday, October 21, 2010
Matrix multiplcation(External Questn-2009)
#include<iostream.h> #include<conio.h> class matrix { int a[10][10],m,n; public: void getdata() { int i,j; cout<<"\n Enter the no of rows and columns "; cin>>m>>n; cout<<"\n Enter the matrix elements "; for(i=0;i<m;i++) for(j=0;j<n;j++) cin>>a[i][j]; } void putdata() { int i,j; for(i=0;i<m;i++) { for(j=0;j<n;j++) cout<<" "<<a[i][j]; cout<<"\n"; } } int checkMulPossible(matrix m1,matrix m2) { if(m1.n==m2.m) return 1; else return 0; } void mulMatrix(matrix m1,matrix m2) { int i,j,k; m=m1.m; n=m2.n; for(i=0;i<m;i++){ for(j=0;j<n;j++) { a[i][j]=0; for(int k=0;k<m1.n;k++) a[i][j]+=(m1.a[i][k]*m2.a[k][j]); } } } }; void main() { clrscr(); matrix mat1,mat2,mat3; cout<<"\nEnter the first matrix details :- "; mat1.getdata(); cout<<"\nEnter the second matrix details :- "; mat2.getdata(); if(mat3.checkMulPossible(mat1,mat2)) { cout<<"\nFirst matrix\n"; mat1.putdata(); cout<<"\nSecond matrix\n"; mat2.putdata(); mat3.mulMatrix(mat1,mat2); cout<<"\nProduct matrix\n"; mat3.putdata(); } else cout<<"\nMultiplication not possible"; getch(); }
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
Home
8085 programming
Datastructure
Graphics programming
8086 Programming
LEX, YACC and parsers
Operating System
Programzz!
Add two date using operator overloading
Add two date using class
Decrement time by one using operator overloading(E...
Add two time using operator overloading(External q...
Compare two string. use operator overloading(Exter...
Matrix multiplcation(External Questn-2009)
Difference between two dates
Generic programming
File manipulation
Pure Virtual Function
Virtual Function
Multipath Inheritance
Hybrid Inheritance
Hierarchical inheritance
Addition of two distances using friend function
Class to class conversion
Basic to class and class to basic conversion
Operator functions as friend functions
Function overloading.
Static & Constant function
User defined string functions
Complex numbers using operator overloading.
Inline function
Add two time
Differnt temprature scale(Farenheit/celsius/kelvin).
Students details- using class
Students details- using structure
Check whether a date is valid or not
pass by value, pass by address, pass by refrence
Followers
Blog Archive
▼
2010
(29)
►
December
(2)
▼
October
(4)
Decrement time by one using operator overloading(E...
Add two time using operator overloading(External q...
Compare two string. use operator overloading(Exter...
Matrix multiplcation(External Questn-2009)
►
July
(1)
►
May
(22)
About Me
Arun Ramesh
View my complete profile
No comments:
Post a Comment