No products in the cart.

Program to multiply two matrix using …

CBSE, JEE, NEET, CUET

CBSE, JEE, NEET, CUET

Question Bank, Mock Tests, Exam Papers

NCERT Solutions, Sample Papers, Notes, Videos

Program to multiply two matrix using class
  • 1 answers

✍️ ? 6 years ago

#include<iostream.h> #include<conio.h> class matrix { int a[10][10]; int m,n; public: void input(); void output(); void multiply(matrix,matrix); }; void matrix::input() { cout<<"Enter the number of row : "; cin>>m; cout<<"Enter the number of column : "; cin>>n; cout<<"Matrix"<<"\n"; for(int i=0;i<m;i++) { for(int j=0;j<n;j++) { cin>>a[i][j]; } } } void matrix :: output() { for(int i=0;i<m;i++) { cout<<"\n"; for(int j=0;j<n;j++) { cout<<a[i][j]<<"\t"; } } } void matrix :: multiply(matrix m1, matrix m2) { if(m1.n!=m2.m) { cout<<"matrix multiplication is not possible"; } else { for(int i=0;i<m1.m;i++) { for(int j=0;j<m2.n;j++) { a[i][j]=0; for(int k=0;k<m1.n;k++) { a[i][j]=a[i][j] +( m1.a[i][k]*m2.a[k][j]); m=m1.m; n=m2.n; } } } } } void main() { clrscr(); matrix m1,m2,m3; m1.input(); m2.input(); m3.multiply(m1,m2); m3.output(); getch(); }
http://mycbseguide.com/examin8/

Related Questions

What is mean by buffering in file handling?
  • 1 answers
What are called tokens
  • 2 answers

myCBSEguide App

myCBSEguide

Trusted by 1 Crore+ Students

Test Generator

Test Generator

Create papers online. It's FREE.

CUET Mock Tests

CUET Mock Tests

75,000+ questions to practice only on myCBSEguide app

Download myCBSEguide App