1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
snow_lady [41]
4 years ago
12

6. Write a program to compute the sum and difference of two matrices which have the same order. Have the user enter the order of

the matrices and then have the user enter the elements in the two matrices, and then perform addition and subtraction of respective elements. You may have to use for loops to obtain the entries of the two matrices and also may have to use for loops to add/subtract the entries.
Computers and Technology
1 answer:
Nadya [2.5K]4 years ago
6 0

Answer:

see explaination

Explanation:

#include<iostream>

using namespace std;

main()

{

int rows,columns,first[10][10], second[10][10], sum[10][10],difference[10][10],i,j;

cout << "Enter number of rows:";

cin >> rows;

cout << "Enter number of columns:";

cin>> columns;

cout << "Enter the elements of first matrix\n";

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

{

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

cin >> first[i][j];

}

cout << "Enter the elements of second matrix\n";

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

{

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

cin >> second[i][j];

}

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

{

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

sum[i][j] = first[i][j] + second[i][j];

}

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

{

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

sum[i][j] = first[i][j] + second[i][j];

}

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

{

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

difference[i][j] = first[i][j] - second[i][j];

}

cout << "Sum of entered matrices:-\n";

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

{

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

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

cout << endl;

}

cout << "Difference of entered matrices:-\n";

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

{

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

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

cout << endl;

}

return 0;

}

see attachment for output

You might be interested in
Set of general format used to write program in any programming language?​
Pavlova-9 [17]
I think It might be Algorithms , algorithmic are a set of instructions that are used to solve a certain problem which of we create many programs…etc
4 0
3 years ago
Regarding Group Policy in Windows Server 2008 and Windows Vista, Microsoft used the token-based administrative template (ADM) fi
melamori03 [73]

Answer:

ADMX files which is in XML file format.

Explanation:

Regarding Group Policy in Windows Server 2008 and Windows Vista, Microsoft used the token-based Administrative Template (ADM) files. Microsoft replaced ADM files with ADMX files (XML-based file format), and it is used in Windows Server 2012 and Windows Server 2012 R2.

ADMX files are registry-based policy settings used for defining the display of the Administrative Template (ADM) policy settings in the GPO Editor in an XML-based structure.

5 0
3 years ago
What are the best 3 xbox 360 games ?​
Andru [333]
Halo
GTA
Call of duty
5 0
4 years ago
Read 2 more answers
8.22 what is the maximum amount of physical memory
sammy [17]
2.16 would be your correct answer or you could refer to the source to actually explain trust me it will help ! the source > coursehero.com
5 0
3 years ago
Why is it important to use safe hand tool?​
xxTIMURxx [149]
Safe tool use contributes to a safer, more efficient work environment.
7 0
3 years ago
Read 2 more answers
Other questions:
  • Each warning label must contain this element and its purpose is to provide a visual alert to users to the chemical hazards to wh
    14·2 answers
  • With which feature or menu option of a word processing program can you make an image like this ?
    15·2 answers
  • There are four types of alignment available from on the Home ribbon toolbar. They include all of the following except
    13·1 answer
  • 1. A microprocessor supports a single hardware timer. Suppose instruction SET_TIMER permits one to set the timer value1. Does th
    15·1 answer
  • Explain the use of cache memory and the role it plays in improving processing speeds. Plz
    15·2 answers
  • The Mark Table of Contents Entry option is used for marking nonheading text for the table of contents. the options are manually
    5·2 answers
  • _____ selectors are used to select elements based on elements that are adjacent to them in the document hierarchy.
    9·1 answer
  • What would a programmer use to stop a while-looping sequence and return to the beginning of the statement?
    11·2 answers
  • Hey, can you guys please help me please??
    14·1 answer
  • A technician is testing a connector in a circuit with a voltmeter. With the power on in the circuit, the meter reads 12 volts wh
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!