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
What is a type of transition used for music in Earsketch
Grace [21]

Answer:

In order to compose music, EarSketch coders can use samples. Audio samples are located in the sound browser, in the left window, which allows for sound file search, and personal sound file upload. In the left section, users can also show the script browser.

No account is required to create projects or view existing projects. EarSketch comprises different elements: a curriculum, a digital audio workstation (or DAW), a code editor and console, and a sound browser.

Dissolves The dissolve is probably the most used transition in video editing. Also known as a cross-dissolve, this effect layers two clips together so there is a seamless transition from one picture to another. You see it everyday and probably don’t even notice it: and that’s the point.

Explanation:

EarSketch is web-based, which means users can access it with their web-browsers, and with no installation. No account is required to create projects or view existing projects. EarSketch comprises different elements: a curriculum, a digital audio workstation (or DAW), a code editor and console, and a sound browser.

8 0
3 years ago
Image editors edit images consisting of thousands of pixels that form this type of image.
lapo4ka [179]
Hi! Did you forget to add something to this?
6 0
2 years ago
Read 2 more answers
Is it possible to do Agile project in Waterfall methodology?
MariettaO [177]
Yes, it could be possilbe
5 0
3 years ago
Read 2 more answers
Create a class named CollegeCourse that includes the following data fields: dept (String) - holds the department (for example, E
frez [133]

Answer:

The answer to this question can be given as:

code:

class CollegeCourse  

{

String Dept;

int CourseNumber;

double Credits;

double fee;

}

Explanation:

We all know that class is a collection of data members and member functions. In the above code we use the following syntax for class declaration that can be given as:

Syntax of class declaration :

class class_name

{

data member & member function

}

In the above code firstly we declare a class that is CollegeCourse. In this class, we define a variable that name and datatype is already given in the question that is String Dept, int CourseNumber, double Credits, double fee. In the variables first variable data type is string. It is used for store string value like ('us','xxx','aaa').The second variable datatype is an integer. It is used for store integer value like (1,23,5,56). The third and fourth variable datatype is the same that is double. This data type is used to store the floating-point value.

5 0
2 years ago
"As part of integrating your solution your client indicates that they have certain technologies enabled on their network that al
erastovalidia [21]

Answer:

quality of service

Explanation:

6 0
2 years ago
Other questions:
  • Which organization publishes a handbook that describes various occupations?
    12·1 answer
  • Fill in the correct term to complete the statement. _____ refers to borrowing money from a bank.
    13·2 answers
  • Electricity was seen as a mysterious force and began to creat a stir when people called​
    13·1 answer
  • What information medium is used to access information from the Internet in the form of HTML pages?
    12·1 answer
  • In addition to telling you which programs are currently running, what other information does the task bar display
    10·1 answer
  • The IBM nine-track tapes that became the industry standard for storage for three decades had several sizes , the most common bei
    13·1 answer
  • Item 8 Item 8 Shelby Black runs a very successful hair salon in downtown Los Angeles. One of Shelby’s tasks is to input positive
    13·1 answer
  • What year did the first hovercraft sail on water
    15·1 answer
  • Please choose odd one out please tell fast ​
    13·2 answers
  • Alvin has created a non-extensive site map of all the commonly visited pages of his website. What is such a site map called?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!