Write a C/C++ program which contain four user define functions mul(), readmat1(), readmat2(),and Display()readmat1 () function read first matrix (array) from user readmat2 () read second matrix (array) from user Display() function display these two matrices and mul() multiply the two matrices (arrays) and display the Resultant Matrix (array). Write main function and call all these function in it.
Write a C/C++ program which contain four user define functions mul(), readmat1(), readmat2(),and Display()read
Class HomeWork {
int mat1[10][10];
int mat2[10][10];
int readmat1();
int readmat2()
void Display()
};
Reply:#include%26lt;stdio.h%26gt;
#include%26lt;conio.h%26gt;
extern int mat1[3][3],mat2[3][3],res[3][3];
void mul( int mat1[3][3],mat2[3][3]);
void readmat1(mat1[3][3]);
void readmat2(ma2[3][3]);
void display(mat1[3][3],mat2[3][3],res[3][3])...
void main()
{
clrscr();
readmat1(mat1);
readmat2(mat2);
mul(mat1,mat2);
display();
getch();
}
void readmat1(mat1[3][3])
{
int i,j;
for(i=0 i%26lt;= 2; i++)
{
for (j=0; j%26lt;=2; j++)
{
printf("\Enter the value for mat1[%d][%d]",i,j);
scanf("%d",%26amp;mat1[i][j]);
}
}
void readmat2(mat2[3][3])
{
int i,j;
for(i=0 i%26lt;= 2; i++)
{
for (j=0; j%26lt;=2; j++)
{
printf("\Enter the value for mat2[%d][%d]",i,j);
scanf("%d",%26amp;mat2[i][j]);
}
}
void mul(mat1[3][3],mat2[3][3])
{
int i,j,k;
for(i=0;i%26lt;=2;i++)
{
for(j=0;j%26lt;=3; j++)
{
res[i][j] = 0;
for(k=0;k%26lt;=2; k++)
res[i][j] += mat1[i][k] * mat2[k][j];
}
}
}
void display(mat1[3][3],mat2[3][3],res[3][3])
{
int i,j;
for(i=0;i%26lt;=2;i++)
{
for(j=0;j%26lt;=2;j++)
printf("%d",mat1[i][j]);
printf("\n");
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment