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]
3 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]3 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
PLEASE HELP!!!!!!!!!!
Shtirlitz [24]
<em>If i was answering this question I would pick D. Because a job is an organization of people working there and the people that work there have a strategic roll on the organization they work for because that's how they make their living!
</em>
7 0
3 years ago
Read 2 more answers
Who developed the idea of a universal network?
polet [3.4K]
Alan Turing fathered the machines we now lovingly call computers, however it was Nicola Tesla that birthed the idea of a world-wide wireless system.
7 0
3 years ago
During which part of geologic time did photosynthesis evolve?
m_a_m_a [10]
During Archean part of geological time photosynthesis evolve.
8 0
3 years ago
Read 2 more answers
Most switches enable you to use multiple nics for a single machine, a process called __________ or link aggregation.
scZoUnD [109]
Bonding.



Good luck! (:
5 0
3 years ago
Betsy loves her job. On a daily basis she problem-solves and uses her creative side to fix situations centered around setting up
vladimir2022 [97]
 
The answer would be an A/V Specialist, because Betsy is working with technical equipment on a TV set.
6 0
3 years ago
Read 2 more answers
Other questions:
  • A design tool helps you plan, evaluate, and explain your ideas to create a product. Some examples of design tools are outlines,
    10·2 answers
  • Daniela’s company has made the decision to allow employees to work from home as the company has outgrown their physical space. K
    13·1 answer
  • "Once a business operations analysis is completed and change needs to
    7·2 answers
  • What is the primary reason that organizations change their structure through downsizing, outsourcing, and offshoring as a means
    14·1 answer
  • Select
    14·1 answer
  • Big data refers to huge collections of data that are difficult to process, analyze, and manage using conventional data tools. It
    13·1 answer
  • Charlie does not think he will be able to finish his project by the deadline at this point in the decision making progress to so
    13·1 answer
  • In science class, Patricia is giving a presentation on the different types of flowers in her community. As part of her presentat
    5·1 answer
  • Ken has discovered that a vice president of his company has been using his computer to send data about a new product to a compet
    15·1 answer
  • Simple interest will always pay more interest than compound interest.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!