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]
2 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:
Alex2 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
Oliver is creating an image of a fruit basket. From the basket, he wants the red apples to stand out among the rest so they will
Volgvan
He   can increase   the   thickness   of the paint on the   apples.
Or he can  use glossier  finish on the   apples  to make them stand out...
3 0
3 years ago
What is a power surge?
Damm [24]
D. A spike of electricity. They are fast and have a short duration.
4 0
2 years ago
How many total numbers can be represented with an 8-bit binary (base-2) system?
ddd [48]

Answer:

256

Explanation:

4 0
3 years ago
What is a fixed expense<br> everfi
Gelneren [198K]

Answer:

A fixed expense is an expense that has a constant total expense value (the total amount of the fixed expense) that remains the same (does not change) when there is a change in the number being managed, manufactured, or sold

Examples of fixed  expense includes; depreciation of assets, salaries of workers, payment for rental lease, and some utility payment, such as road users toll fees payment at a toll gate

Explanation:

8 0
2 years ago
Can you please make a simple python program? I will give you 20 points and branliest if it is good! It must include:
alekssr [168]

Answer:

# Solve the quadratic equation ax**2 + bx + c = 0

# import complex math module

import cmath

a = 1

b = 5

c = 6

# calculate the discriminant

d = (b**2) - (4*a*c)

# find two solutions

sol1 = (-b-cmath.sqrt(d))/(2*a)

sol2 = (-b+cmath.sqrt(d))/(2*a)

print('The solution are {0} and {1}'.format(sol1,sol2))

Hope This Helps!!!

3 0
2 years ago
Read 2 more answers
Other questions:
  • Assume arr2 is declared as a two-dimensional array of integers. Which of the following segments of code successfully calculates
    6·1 answer
  • Which interest bearing account is best for people who won’t need access to their money for several months or longer?
    6·1 answer
  • You would like to search for information about storms but not tornadoes. What type of search strategy may be useful?
    10·2 answers
  • When performing actions between your computer and one that is infected with a virus, which of the following offers NO risk of yo
    11·1 answer
  • In a Windows environment, __________ is a powerful tool that enables security administrators to share user and group definitions
    10·1 answer
  • Which of the following statement is correct? Select one: a. Base register holds the size of a process. b. Limit register holds t
    10·1 answer
  • Pls help I will give points
    11·1 answer
  • How much do you think it would cost to develop an app?
    14·2 answers
  • Which web-authoring software enables users to create sophisticated web pages without knowing any html code?.
    15·1 answer
  • What would be an ideal scenario for using edge computing solutions?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!