2023 Rewrite the matrix program using Pass by Reference include stdio h include stdlib h include cmath include string h include math h int main | Assignment Collections
Computer Science 2023 Rewrite The Matrix Program Using Pass-by-Reference:
2023 Rewrite the matrix program using Pass by Reference include stdio h include stdlib h include cmath include string h include math h int main | Assignment Collections
Rewrite the matrix program using Pass-by-Reference:
#include <stdio.h>
#include <stdlib.h>
#include <cmath>
#include <string.h>
#include <math.h>
int main() {
int m, a, p, q, c, d, k, matrix, total = 0;
int first[3][3], second[3][3], multiply[3][3], addition[3][3], transpose[3][3];
printf(“Enter number of rows and columns of first matrixn”);
scanf(“%d%d”, &m, &a);
printf(“Enter elements of first matrixn”);
for (c = 0; c < m; c++)
for (d = 0; d < a; d++)
scanf(“%d”, &first[c][d]); //first matrix
printf(“Enter number of rows and columns of second matrixn”);
scanf(“%d%d”, &p, &q);
printf(“Enter elements of second matrixn”);
for (c = 0; c < p; c++)
for (d = 0; d < q; d++)
scanf(“%d”, &second[c][d]);
do {
printf(“n1. Multiplication of the 2 Matricesn”);
printf(“2. Addition of the 2 Matricesn”);
printf(“3. Transposition of the 2 Matricesn”);
printf(“4. Go back to Main Menun”);
printf(“Choose a number: n”);
scanf(“%d”, &matrix);
if (matrix == 1) {
for (c = 0; c < m; c++) {
for (d = 0; d < q; d++) {
for (k = 0; k < p; k++) {
total = total + first[c][k]*second[k][d];
}
multiply[c][d] = total;
total = 0;
}
}
printf(“nProduct of the matrices:n”);
for (c = 0; c < m; c++) {
for (d = 0; d < q; d++)
printf(“%dt”, multiply[c][d]);
printf(“n”);
}
}//end of choice 1
else if (matrix == 2) {
printf(“Sum of entered matrices: n”);
for (c = 0; c < m; c++) {
for (d = 0 ; d < a; d++) {
addition[c][d] = first[c][d] + second[c][d];
printf(“%dt”, addition[c][d]);
}
printf(“n”);
}
}//end of choice 2
else if (matrix == 3) {
for (c = 0; c < m; c++)
for( d = 0 ; d < a ; d++ )
transpose[d][c] = first[c][d];
for (c = 0; c < m; c++)
for( d = 0 ; d < a ; d++ )
transpose[d][c] = second[c][d];
printf(“Transpose of the matrix:n”);
for (c = 0; c < a; c++) {
for (d = 0; d < m; d++)
printf(“%dt”, transpose[c][d]);
printf(“n”);
}
}//end of choice 3
else if (matrix == 4) {
//exit
}
else if (matrix >= 5) {
printf(“INVALID INPUT, please try again”);
}
}while(matrix!=4);
return 0;
}
We give our students 100% satisfaction with their assignments, which is one of the most important reasons students prefer us to other helpers. Our professional group and planners have more than ten years of rich experience. The only reason is that we have successfully helped more than 100000 students with their assignments on our inception days. Our expert group has more than 2200 professionals in different topics, and that is not all; we get more than 300 jobs every day more than 90% of the assignment get the conversion for payment.