answersLogoWhite

0


Best Answer

#include<iostream.h>

#include<conio.h>

#include<process.h>

class mat

{

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

int i,j,k,p,q,x,y;

public:

void addition(void);

void substraction(void);

void multiplication(void);

};

void mat::addition()

{

cout<<"\nENTER THE DIMENSION OF MATRIX A::\t";

cin>>x>>y;

cout<<"\nENTER THE DIMENSION OF MATRIX b::\t";

cin>>p>>q;

if((x==p)&&(y==q))

{

cout<<"\nENTER THE"<<x<<"*"<<y<<"ELEMENTS OF MATRIX A::\n";

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

{

for(j=0;j<y;j++)

cin>>a[i][j];

}

cout<<"\nENTER THE"<<p<<"*"<<q<<"ELEMENTS OF MATRIX B::\n";

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

{

for(j=0;j<q;j++)

cin>>b[i][j];

}

cout<<"\nSUM OF MATRIX A & B::\n";

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

{

for(j=0;j<y;j++)

c[i][j]=a[i][j]+b[i][j];

}

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

{

for(j=0;j<y;j++)

cout<<c[i][j]<<"\t";

cout<<"\n";

}

}

else

cout<<"\nADDITION IS NOT POSSIBLE::";

}

void mat::substraction()

{

cout<<"\nENTER THE DIMENSION OF MATRIX A::\t";

cin>>x>>y;

cout<<"\nENTER THE DIMENSION OF MATRIX b::\t";

cin>>p>>q;

if((x==p)&&(y==q))

{

cout<<"\nENTER THE"<<x<<"*"<<y<<"ELEMENTS OF MATRIX A::\n";

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

{

for(j=0;j<y;j++)

cin>>a[i][j];

}

cout<<"\nENTER THE"<<p<<"*"<<q<<"ELEMENTS OF MATRIX B::\n";

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

{

for(j=0;j<q;j++)

cin>>b[i][j];

}

cout<<"\nDIFFERENCE OF THE MATRIX A & B::\n";

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

{

for(j=0;j<y;j++)

c[i][j]=a[i][j]-b[i][j];

}

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

{

for(j=0;j<y;j++)

cout<<c[i][j]<<"\t";

cout<<"\n";

}

}

else

cout<<"\nSUBSTRACTION IS NOT POSSIBLE::";

}

void mat::multiplication()

{

cout<<"\nENTER THE DIMENSION OF MATRIX A::\t";

cin>>x>>y;

cout<<"\nENTER THE DIMENSION OF MATRIX b::\t";

cin>>p>>q;

if(y==q)

{

cout<<"\nENTER THE"<<x<<"*"<<y<<"ELEMENTS OF MATRIX A::\n";

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

{

for(j=0;j<y;j++)

cin>>a[i][j];

}

cout<<"\nENTER THE"<<p<<"*"<<q<<"ELEMENTS OF MATRIX B::\n";

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

{

for(j=0;j<q;j++)

cin>>b[i][j];

}

cout<<"\nPROCUCT OF THE MATRIX A & B::\n";

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

{

for(j=0;j<q;j++)

{

c[i][j]=0;

for(k=0;k<y;k++)

c[i][j]=a[i][k]*b[k][i]+c[i][j];

}

}

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

{

for(j=0;j<q;j++)

cout<<c[i][j]<<"\t";

cout<<"\n";

}

}

else

cout<<"\nMULTIPLICATION IS NOT POSSIBLE::";

}

void main()

{

int c;

char ch;

mat M;

do

{

clrscr();

cout<<"\t\tMATRIX OPERATION\n\n";

cout<<"\n1.ADDITION\n2.SUBSTRACTION\n3.MULTIPLICATION\n";

cout<<"\nENTER YOUR CHOICE::\t";

cin>>c;

switch(c)

{

case 1:

M.addition()

break;

case 2:

M.substraction()

break;

case 2:

M.multiplication()

break;

default;

cout<<"Wrong Choice";

}

cout<<"\nDoyou want to continue[y/n]::\t";

cin>>ch;

}

while(ch=='y'ch=='Y');

getch();

}

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Create a class mat of size m x n define the following matrix operations for mat type objects a addition b subtraction c multiplication?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Symbol that specify addition substraction multiplication?

+ addition - subtraction* multiplication


For a new C-Sharp coder What do Operators do?

An operator in C# performs a specific operation like addition, subtraction, multiplication etc.


What are the mathematical order of operators in Java programming?

Mathematical operators have the standard precedence: parenthesis (brackets), orders (powers), multiplication/division, addition/subtraction. x + y * z implies x + (y * z) because multiplication has higher precedence than addition. When two operators have the same precedence (such as addition and subtraction), they are evaluated left to right. Thus x - y + z implies (x - y) + z.


What is the example of binary operator?

There are many: addition, subtraction, multiplication and division are the most common. Each of these operators acts on two numbers to produce a third (which may not be different).


What is matrix programming in C programming?

C Examples on Matrix OperationsA matrix is a rectangular array of numbers or symbols arranged in rows and columns. The following section contains a list of C programs which perform the operations of Addition, Subtraction and Multiplication on the 2 matrices. The section also deals with evaluating the transpose of a given matrix. The transpose of a matrix is the interchange of rows and columns.The section also has programs on finding the trace of 2 matrices, calculating the sum and difference of two matrices. It also has a C program which is used to perform multiplication of a matrix using recursion.C Program to Calculate the Addition or Subtraction & Trace of 2 MatricesC Program to Find the Transpose of a given MatrixC Program to Compute the Product of Two MatricesC Program to Calculate the Sum & Difference of the MatricesC Program to Perform Matrix Multiplication using Recursion

Related questions

What is the operations that undo each other?

Inverse Operations: Divison undoes multiplication. Addition undoes subtraction. Subtraction undoes addition. Multiplication undoes division.


What operations are closed for integers?

Addition, subtraction and multiplication.


What are the fundamental operation of math?

the fundamental operations in math are, addition +, subtraction -, division /,and multiplication x ..


How would 2 pond 60 be shown on a calculator display?

The answer will depend on how the information was entered - in pounds (or ponds) or in pennies, what the operations were - addition/subtraction or -multiplication/division).The answer will depend on how the information was entered - in pounds (or ponds) or in pennies, what the operations were - addition/subtraction or -multiplication/division).The answer will depend on how the information was entered - in pounds (or ponds) or in pennies, what the operations were - addition/subtraction or -multiplication/division).The answer will depend on how the information was entered - in pounds (or ponds) or in pennies, what the operations were - addition/subtraction or -multiplication/division).


Which to operations are done first division or subtraction or multiplacation or addition?

Do (multiplication/division) before you do (addition/subtraction).


What is 4 fundamental operations?

They are: addition, subtraction, division and multiplication


What is real number operations?

multiplication-addition-subtraction-division


What are the four operations of arithmetic?

+ - addition _ - subtraction * - multiplication / - division


What are the basic algebraic operations?

addition,subtraction,multiplication,division


What is arithmetic?

Arithmetic is the process of applying the four basic operations: addition, subtraction, multiplication and division to numbers.


What are the five mathematical operations?

Multiplication, Division, Subtraction, Addition and the carrot(^) making the following number an exponent or exponential number


What are the methods of four fundamental operations?

addition,subtraction multiplication,division.