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
PIT_PIT [208]
3 years ago
11

Write a program that generates two 3x3 matrices, A and B, withrandom values in the range [1, 100] and calculates the expression½

A + 3B
Computers and Technology
1 answer:
Alex3 years ago
6 0

Answer:

#include <bits/stdc++.h>

using namespace std;

int main() {

int A[3][3],B[3][3],res[3][3],i,j;

srand(time(0));//for seed.

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

{

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

{

   int val=rand()%100+1;//generating random values in range 1 to 100.

   int val2=rand()%100+1;

   A[i][j]=val;

   B[i][j]=val2;

}

cout<<endl;

}

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

{

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

   {

       res[i][j]=0.5*A[i][j]+3*B[i][j];//storing the result in matrix res.

   }

}

cout<<"Matrix A is"<<endl;

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

{

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

   {

       cout<<A[i][j]<<" ";//printing matrix A..

   }

   cout<<endl;

}

cout<<"Matrix B is"<<endl;

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

{

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

   {

       cout<<B[i][j]<<" ";//printing matrix B..

   }

   cout<<endl;

}

cout<<"The result is"<<endl;

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

{

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

   {

       cout<<res[i][j]<<" ";//printing the result..

   }

   cout<<endl;

}

return 0;

}

Output:-

Matrix A is

13 95 83  

88 7 14  

24 22 100  

Matrix B is

11 13 95  

48 35 20  

68 100 18  

The result is

39.5 86.5 326.5  

188 108.5 67  

216 311 104  

Explanation:

I have created 2 matrices A and B and storing random numbers int the matrices A and B.Then after that storing the result in res matrix of type double to store decimal values also.Then printing the res matrix.

You might be interested in
A horse is how much percent more powerful than a pony
KatRina [158]
A horse is much percent more powerful than a pony by 1000
4 0
3 years ago
When a program is adapted to run on multiple processors in a multiprocessor system, the execution time on each processor is comp
____ [38]
I only need points for my questions
4 0
3 years ago
I re-made the human version of Daddy Dearest from Friday Night Funkin
schepotkina [342]
I like the second one better xx
6 0
3 years ago
Read 2 more answers
Follow me please.........​
devlian [24]

thank you for the free points.

4 0
3 years ago
How do u set up a Wi-Fi network on Android ​
AlladinOne [14]

Answer:

These are some way I know

5 0
3 years ago
Other questions:
  • What 2 major agricultural inventions did jethro tull create?
    10·2 answers
  • A network that operates without relying on a server is the ________ network.
    6·1 answer
  • A binary search can be performed only on ____.
    6·1 answer
  • The control programs managing computer hardware and software perform the _________ function to control and prioritize tasks perf
    8·1 answer
  • Which of the following sorting algorithms could be implemented on a doubly-linked list WITHOUT making the asymptotic worst-case
    12·1 answer
  • What is the most effective way to demonstrate being prepared for an interview?
    8·2 answers
  • Plz help need answers!???idk if u can zoom
    13·1 answer
  • What is unique about the TODAY and NOW functions?
    15·2 answers
  • The main difference between \f and \r is that \f produces a
    13·1 answer
  • Add the following numbers in abacus 2436+9214​
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!