Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please answer the following using DEV C++ and WITHOUT the use of functions like

ID: 3676215 • Letter: P

Question

Please answer the following using DEV C++ and WITHOUT the use of functions like "cout" "cin" etc. PLEASE USE functions like "printf()" "scanf()" etc >> #include<stdio.h> instead. This is because my program does not support functions like cout and cin. THANK YOU!

Create a script that will create a program to find the product of two matrices... Condition:s The program will ask a user the dimensions of matrices A and B (row and column sizes) The program will ask the user to type in individual entry of the matrices based on the row and column number. (row first!) The program will make a decision whether two input matrices are COMPATIBLE FOR MULTIPLICATION. The program will display two matrices. Then show the C matrix which is the product of A and B (C-A B)

Explanation / Answer

Please find the required program below :

#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
int a[10][10], b[10][10], mult[10][10], r1, c1, r2, c2, i, j, k;
printf("Enter rows and columns for first matrix: ");
scanf("%d %d",&r1,&c1);
printf("Enter rows and columns for second matrix: ");
scanf("%d %d",&r2,&c2);

/* If colum of first matrix in not equal to row of second matrix*/
if (c1!=r2)
{
printf("Error! column of first matrix not equal to row of second.");
printf("Not compatible for multiplication");
}

/* Storing elements of first matrix. */
printf("Enter elements of matrix 1:");
for(i=0; i<r1; ++i)
for(j=0; j<c1; ++j)
{
printf("Enter elements of A %d %d :",(i+1),(j+1));
scanf("%d",&a[i][j]);
}

/* Storing elements of second matrix. */
printf("Enter elements of matrix 2:");
for(i=0; i<r2; ++i)
for(j=0; j<c2; ++j)
{
printf("Enter element of B %d %d :",(i+1),(j+1));
scanf("%d",&b[i][j]);
}

/* Diplaying first matrix. */
for(i=0; i<r1; ++i)
for(j=0; j<c1; ++j)
{
printf("%d",a[i][j]);
}

/* Diplaying second matrix. */
for(i=0; i<r2; ++i)
for(j=0; j<c2; ++j)
{
printf("%d",b[i][j]);
}
  
/* Initializing elements of matrix mult to 0.*/
for(i=0; i<r1; ++i)
for(j=0; j<c2; ++j)
{
mult[i][j]=0;
}

/* Multiplying matrix a and b and storing in array mult. */
for(i=0; i<r1; ++i)
for(j=0; j<c2; ++j)
for(k=0; k<c1; ++k)
{
mult[i][j]+=a[i][k]*b[k][j];
}

/* Displaying the multiplication of two matrix. */
cout << endl << "Output Matrix: " << endl;
for(i=0; i<r1; ++i)
for(j=0; j<c2; ++j)
{
printf("%d ",mult[i][j]);
if(j==c2-1)
cout << endl;
}
return 0;
}