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
Convert the following C program to C++.
ki77a [65]

Answer:

The program equivalent in C++ is:

<em>#include <cstdio></em>

<em>#include <cstdlib></em>

#define SIZE 5

using namespace std;

<em>int main(int argc, char *argv[]) {</em>

<em>int numerator = 25;</em>

<em>int denominator = 10;</em>

<em>FILE * inPut = fopen(argv[1], "r");</em>

<em>FILE * outPut = fopen(argv[2], "w");</em>

<em>float result = (float)numerator/denominator;</em>

<em>fprintf(outPut,"Result is %.2f\n", result);</em>

<em>float arr[SIZE];</em>

<em>for(int i = 0; i < SIZE; i++) {</em>

<em>fscanf(inPut, "%f", &arr[i]);</em>

<em>fprintf(outPut, "%7.4f\n", arr[i]);</em>

<em>}</em>

<em>return 0;</em>

<em>}</em>

Explanation:

See attachment for explanation.

Each line were numbered with equivalent line number in the C program

Download cpp
8 0
3 years ago
How would you define a relational database ?
UNO [17]

Answer: (D) Database design follows the twelve principles proffered by Dr. Edgar F. Codd

Explanation:

 The relational database is basically based on the relational model of the data which is proposed by the Dr Edger F. codd and he mainly introduced the twelve basics principle of the database designing in the database system. He also contributed various valuable principle in the computer science.

The twelve principle are:

  • The first rule of the relational database is the information rule as it represented all data or information
  • Independence of the integrity
  • Viewing various updating rule
  • Logically treatment of various NULL value
  • Independence of the physical database
  • Distribution in-dependency
  • Various delete, insert and update rules
  • The overall logical description of the database are basically stored in the database directory
  • There is no subversion rule
  • There is guarantee accessing rule
  • Proper rule for data language
  • The relational database level actions

7 0
3 years ago
In popular usage and in the media, the term ________ often describes someone who breaks into a computer system without authoriza
ch4aika [34]
The answer here is hacker
6 0
3 years ago
You can clear a log file simply by redirecting nothing into it. true or false?
nekit [7.7K]
True

cat /dev/null > fileName


------------------------------------
6 0
4 years ago
D) Informal high level descuption of an algorithm in english kcalled
Hatshy [7]
It might be d I’m not sure die
8 0
3 years ago
Read 2 more answers
Other questions:
  • Why do local variables lose their values between calls to the function in which they are
    5·1 answer
  • Each of the following programs has errors. Find as many as you can. 65. // Find the error in this program. #include using namesp
    5·1 answer
  • Allison, a very close friend of yours, is about to give a presentation to the class. You know that she has procrastinated and is
    14·2 answers
  • An administrative assistant types a document, saves, and prints. The assistant is using _____.
    14·1 answer
  • Users are reporting Internet connectivity issues. The network administrator wants to determine if the issues are internal to the
    15·1 answer
  • Write a public static method named evens that takes in 1 argument int a, and returns a String containing all positive even numbe
    8·1 answer
  • A. Choose the correct answer.
    8·2 answers
  • My uh coding teacher would like the class to do little piggy with code.
    10·1 answer
  • Function of printer and speaker​
    5·1 answer
  • Do you need to have java on your computer.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!