Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

for this task could you please as soon as possible, this is C language Rewrite the code by using the following two functions: Function 1:

for this task could you please as soon as possible, this is C language

Rewrite the code by using the following two functions:

Function 1: it is used to input the elements of a matrix to a given array.

Function 2: it is used to display all elements from the product of a matrix.

Write the two functions and replace the original codes with both new functions.

here is the original code

#include int main() { int m, n, p, q, c, d, k, sum = 0; /* first, second and multiply array is used to store the first matrix, the second matrix and multiplied result respectively*/ int first[10][10], second[10][10], multiply[10][10]; printf("Enter number of rows and columns of first matrix "); scanf("%d%d", &m, &n); printf("Enter elements of first matrix "); for (c = 0; c < m; c++) for (d = 0; d < n; d++) scanf("%d", &first[c][d]); printf("Enter number of columns of second matrix "); scanf("%d%d",&p, &q); printf("Enter elements of second matrix "); for (c = 0; c < n; c++) for (d = 0; d < q; d++) scanf("%d", &second[c][d]); for (c = 0; c < m; c++) { for (d = 0; d < q; d++) { for (k = 0; k < p; k++) { sum = sum + first[c][k]*second[k][d]; } multiply[c][d] = sum; sum = 0; } } printf("Product of the matrices: "); for (c = 0; c < m; c++) { for (d = 0; d < q; d++) printf("%d\t", multiply[c][d]); printf(" "); } }

Thank you

for anyone that sees the answer for this code please change it a bit

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Database Systems Design Implementation And Project Management

Authors: Albert K.W. Yeung, G. Brent Hall

1st Edition

1402053932, 978-1402053931

More Books

Students also viewed these Databases questions