/*==========================================
calculation of product of two matrix........
written by kr.gauraw
==========================================*/
#include<stdio.h>
#include<conio.h>
void main()
{
int mat1[3][3],mat2[3][3],mat3[3][3],i,j,k,sum;
clrscr();
printf("\nEnter values for 1st 3 x 3 matrix:\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf("%d",&mat1[i][j]);
}
}
printf("\nEnter values for 2nd 3 x 3 matrix:\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf("%d",&mat2[i][j]);
}
}
printf("\nThe 1st matrix you entered is :\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("%d\t",mat1[i][j]);
}
printf("\n");
}
printf("\nThe 2nd matrix you entered is:\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("%d\t",mat2[i][j]);
}
printf("\n");
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
sum=0;
for(k=0;k<3;k++)
{
sum=sum+mat1[i][k]*mat2[k][i];
}
mat3[i][j]=sum;
}
}
printf("\nThe product of two above matrix is:\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("%d\t",mat3[i][j]);
}
printf("\n");
}
printf("\n\n\nPress any key to exit.....");
getch();
}
you can try it by using matrix multiplication(also sum is given)........... the code is given below...
#include<stdio.h>
#include<conio.h>
void main()
{
int i, j, k, r1, r2, c1, c2, sum1;
int m1[10][10], m2[10][10], sum[10][10], mult[10][10];
printf("\n Enter the no of rows & column for matrix m1: ");
scanf("%d %d", &r1, &c1);
printf("\n Enter the elements for matrix m1 row wise: ");
for(i=0;i<r1;i++)
{
for(j=0;j<c1;j++)
scanf("%d", &m1[i][j]);
}
printf("\n Enter the no of row & column for matrix m2 :");
scanf("%d %d", &r2, &c2);
printf("\n enter the elememts for matrix m2 row wise: ");
for(i=0;i<r2;i++)
{
for(j=0;j<c2;j++)
scanf("%d", &m2[i][j]);
}
printf("\n The matrix m1 is: ");
for(i=0;i<r1;i++)
{
printf("\n");
for(j=0;j<c1;j++)
{
printf(" %3d", m1[i][j]);
}
}
printf("\n The matrix m2 is: ");
for(i=0;i<r2;i++)
{
printf("\n");
for(j=0;j<c2;j++)
{
printf(" %3d", m2[i][j]);
}
}
if(r1==r2 && c1==c2)
{
printf("\n The matrix sum is: ");
for(i=0;i<r1;i++)
{
printf("\n");
for(j=0;j<c1;j++)
{
sum[i][j]=0;
sum[i][j]=m1[i][j]+m2[i][j];
printf(" %3d", sum[i][j]);
}
}
}
else
printf("\n The matrix sum is not possible");
if(c1==r2)
{
printf("\n The matrix multiplication is: ");
for(i=0;i<r1;i++)
{
printf("\n");
for(j=0;j<c2;j++)
{
mult[i][j]=0;
sum1=0;
for(k=0;k<r1;k++)
{
mult[i][j]=m1[i][k]*m2[k][j];
sum1=mult[i][j]+sum1;
}
printf(" %3d", sum1);
}
}
}
else
printf("\n The multiplication is not possible");
getch();
}
### Samaresh Bera (IIT Kharagpur)
#include<stdio.h> #include<conio.h>
void main()
{
int a[10],b[10],m[10];
int m,n,l,p,i,j,k;
printf("\n Enter row of first matrix(<=10)");
scanf("%d",&n);
printf("Enter column of first matrix(<=10)");
scanf("%d",&m);
printf("enter row of second matrix(<=10)");
scanf("%d",&l);
printf("Enter column of second matrix(<=10)");
scanf("%d",&p);
printf("Enter first matrix");
for(i=0;i<=n-1;i++)
{
for(j=0;j<=m-1;j++)
{
scanf("%d",&a[i][j];
}
}
printf("Enter second matrix");
for(i=0;i<=l-1;i++)
Here it is
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i,j,k,s,r1,r2,c1,c2;
int a[100][100],b[100][100],c[100][100];
cin>>r1>>c1>>r2>>c2;
if(c1==r2)
{ cout<<"arr1 ";
for(i=0;i<r1;i++)
{
for(j=0;j<c1;j++)
cin>>a[i][j];
}
cout<<"arr2 ";
for(i=0;i<r2;i++)
{
for(j=0;j<c2;j++)
cin>>b[i][j];
}
for(i=0;i<r1;i++)
{
for(j=0;j<c2;j++)
{
s=0;
for(k=0;k<c1;k++)
{
s=s+(a[i][k]*b[k][j]);
}
c[i][j]=s;
}
}
cout<<endl;
for(i=0;i<r1;i++)
{
for(j=0;j<c1;j++)
cout<<a[i][j]<<" ";
cout<<endl;
}
cout<<endl<<endl;
for(i=0;i<r2;i++)
{
for(j=0;j<c2;j++)
cout<<b[i][j]<<" ";
cout<<endl;
}
cout<<endl<<endl;
for(i=0;i<r1;i++)
{
for(j=0;j<c2;j++)
cout<<c[i][j]<<" ";
cout<<endl;
}
}
else
{
cout<<"error";
}
getch();
}
#include <stdio.h>
void mult_matrices(int a[][3], int b[][3], int result[][3]);
void print_matrix(int a[][3]);
int main()
{
int p[3][3] = {{1, 2, 3},{4, 5, 6}, {7, 8, 9}};
int q[3][3] = {{10, 11, 12}, {13, 14, 15}, {16, 17, 18}};
int r[3][3];
mult_matrices(p, q, r);
print_matrix(r);
}
void mult_matrices(int a[][3], int b[][3], int result[][3])
{
int i, j, k;
for(i = 0; i < 3; i++)
{
for(j = 0; j < 3; j++)
{
for(k = 0; k < 3; k++)
{
result[i][j] += a[i][k] * b[k][j];
}
}
}
}
void print_matrix(int a[][3])
{
int i, j;
for (i = 0; i < 3; i++)
{
for(j = 0; j < 3; j++)
{
printf("%d\t", a[i][j]);
}
printf("\n");
}
}
C Examples on Matrix OperationsA matrix is a rectangular array of numbers or symbols arranged in rows and columns. The following section contains a list of C programs which perform the operations of Addition, Subtraction and Multiplication on the 2 matrices. The section also deals with evaluating the transpose of a given matrix. The transpose of a matrix is the interchange of rows and columns.The section also has programs on finding the trace of 2 matrices, calculating the sum and difference of two matrices. It also has a C program which is used to perform multiplication of a matrix using recursion.C Program to Calculate the Addition or Subtraction & Trace of 2 MatricesC Program to Find the Transpose of a given MatrixC Program to Compute the Product of Two MatricesC Program to Calculate the Sum & Difference of the MatricesC Program to Perform Matrix Multiplication using Recursion
/*PROGRAM TO ACCEPT TWO NUMBERS FROM THE USER AND PRINT THEIR MULTIPLICATION. */ #include<stdio.h> #include<conio.h> void main() { int a, b, c; // Declaration of Variables. Variables 'a' & 'b' to hold first & second number. And 'c' to hold result. clrscr(); // To clear the output screen every time program is executed. printf("\n Enter the first number : "); scanf("%d", &a); // To accept the first number. printf("\n Enter the second number : "); scanf("%d", &b); // To accept the second number. c = a*b; // Logic to get the product of the entered two numbers. printf("\n Multiplication of %d & %d = %d", a, b, c); // Displaying result. getch(); // To hold the output screen. }
maltiplication of matrix for algorithme
c program was introduced in the year 1972 by Dennis RitchieNo, it was the C language, not the C program.
how to create a c program for left factoring.
The matrix multiplication in c language : c program is used to multiply matrices with two dimensional array. This program multiplies two matrices which will be entered by the user.
Clouser
GOUDHMARINI
That property is called CLOSURE.
Poor boy
Yes, because there is no way of multiplying two polynomials to get something that isn't a polynomial.
To get a quotient and a remainder, you would need to do a division, not a multiplication.
An expression made with constants, variables and exponents, which are combined using addition, subtraction and multiplication, ... but not division.
A polynomial is any number of the form Ax^n + Bx^n-1 + ... + c. So, multiplying numbers with exponents with any other numbers with exponents in polynomials only results in another, larger polynomial. Since this is multiplication, you could call the resultant polynomial a product.
It means that you can do any of those operations, and again get a number from the set - in this case, a polynomial. Note that if you divide a polynomial by another polynomial, you will NOT always get a polynomial, so the set of polynomials is not closed under division.
Yes. Factoring a polynomial means to separate it into smaller factors, which, when multiplied together, give you the original polynomial.
a*(b + c) = a*b + a*c