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
IRINA_888 [86]
3 years ago
11

6. Write a program that can multiply an n x m matrix and m x n matrix together: The input specifications are these: Read n and m

using scanf function. Read two matrices using a for loop inside the main function. The output (product) matrix must be computed in a function named matrix_mult which will have the two input matrices as arguments.
Computers and Technology
1 answer:
Whitepunk [10]3 years ago
7 0

Answer:

see explaination

Explanation:

#include <stdio.h>

#include <malloc.h>

void matrix_mult(int **m1, int **m2, int **m3, int n, int m) {

int i, j, k, sum=0;

for(i = 0; i < n; ++i) {

for(j = 0; j < n; ++j) {

sum = 0;

for(k = 0; k < m; ++k) {

sum += m1[i][k] * m2[k][j];

}

m3[i][j] = sum;

}

}

}

int main() {

int n, m, i, j;

int **m1, **m2, **m3;

printf("Enter number of rows: ");

scanf("%d", &n);

printf("Enter number of columns: ");

scanf("%d", &m);

m1 = malloc(sizeof(int *) * n);

m2 = malloc(sizeof(int *) * m);

m3 = malloc(sizeof(int *) * n);

for(i = 0; i < m; ++i) {

m1[i] = malloc(sizeof(int) * m);

m2[i] = malloc(sizeof(int) * n);

m3[i] = malloc(sizeof(int) * n);

}

printf("Enter first matrix\n");

for(i = 0; i < n; ++i) {

for(j = 0; j < m; ++j) {

scanf("%d", &(m1[i][j]));

}

}

printf("Enter second matrix\n");

for(i = 0; i < m; ++i) {

for(j = 0; j < n; ++j) {

scanf("%d", &(m2[i][j]));

}

}

matrix_mult(m1, m2, m3, n, m);

printf("product is\n");

for(i = 0; i < n; ++i) {

for(j = 0; j < n; ++j) {

printf("%d ", m3[i][j]);

}

printf("\n");

}

printf("Enter first matrix: ");

return 0;

}

You might be interested in
One horsepower is equal to how many foot-pounds of work per second?
erastovalidia [21]
The answer is d hope this helps lol
6 0
3 years ago
Read 2 more answers
The process of encoding messages or information in such a way that only authorized parties can read it is called ____________.
lukranit [14]

Answer:

Encryption

Explanation:

Encryption is a term in the field of computer security (Cryptology) this is a process of encoding information in a way that hackers and eavesdroppers cannot read. The process of encryption involves a plain text (message) been converted into a scrambled text (cipher text) with an encryption algorithm (key) in this way, if the message is intercepted by a hacker he/she is unable to read the contents. Only the authorized party with a decryption key will be able to decrypt back to a plain text and read the contents of the message

3 0
3 years ago
If your vehicle leaves the pavement for any reason, remember to take your foot off the gas pedal, hold the wheel firmly, and____
aleksandr82 [10.1K]
A- and steer in a straight line 
8 0
3 years ago
Read 2 more answers
What is the distance from the end of the pin to the center of the hole?
Lemur [1.5K]

Answer:

Roughly 7/8 on the pinhole, roughly 2-1/4" from the pinhole to end of the adapter.

Explanation:

8 0
2 years ago
Sharing a workbook enables multiple users to access the workbook. What are the benefits of using a shared workbook?
damaskus [11]

Answer:

Some of the benefits of sharing a workbook include:

A. Shared information between students (ie: Mary writes a note about (blank) in the workbook and John reads said note and receives addition information about (blank)).

B. ^adding onto this, discussion on interpretations of a passage (ie: John thinks (blank) means this and Mary thinks (blank) means other thing, through notes they can discuss the meaning of the text.

Hope this helps. =)

8 0
3 years ago
Other questions:
  • A technician is tasked to implement a wireless router that will have the fastest data transfer speed at 5 GHz frequency. Which o
    11·1 answer
  • Data warehousing and data mining mean the same thing when applied to CRM
    7·2 answers
  • If you see an icon in a document preset that looks like a tiny web browser window, what type of document is the preset meant to
    13·1 answer
  • What in the LAN for a small office, some user devices connect to the LAN using a cable, while others connect using wireless tech
    14·1 answer
  • In which table is the input and the corresponding output of a Boolean function listed? How is the output of the NAND gate determ
    9·1 answer
  • The best way to safeguard your document is to save it
    11·1 answer
  • Impact of information technology in the society​
    11·1 answer
  • What is the first phone ever made?
    6·1 answer
  • One rule in the Java programming language is that you have to place a semicolon at the end of each statement. What is this rule
    10·2 answers
  • What is a for command? can u use a variable instead of a number in the for command!<br>​
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!