answersLogoWhite

0


Best Answer

/*==========================================

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();

}

User Avatar

Wiki User

12y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

11y ago

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)

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

#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++)

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

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();

}

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

#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");

}

}

This answer is:
User Avatar

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: C program for polynomial multiplication
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is matrix programming in C programming?

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


A c program for multiplication of two integers a and b?

/*PROGRAM TO ACCEPT TWO NUMBERS FROM THE USER AND PRINT THEIR MULTIPLICATION. */ #include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main() { int a, b, c; // Declaration of Variables. Variables 'a' &amp; 'b' to hold first &amp; 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", &amp;a); // To accept the first number. printf("\n Enter the second number : "); scanf("%d", &amp;b); // To accept the second number. c = a*b; // Logic to get the product of the entered two numbers. printf("\n Multiplication of %d &amp; %d = %d", a, b, c); // Displaying result. getch(); // To hold the output screen. }


Cannon matrix multiplication program?

maltiplication of matrix for algorithme


C program was introduced in the year?

c program was introduced in the year 1972 by Dennis RitchieNo, it was the C language, not the C program.


C program on left factoring in compiler design?

how to create a c program for left factoring.

Related questions

Program to display multiplication of two matrix?

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.


What property of polynomial multiplication says that the product of two polynomials is always a polynomial?

Clouser


Write a c program add two polynomial using link list?

GOUDHMARINI


Which property of polynomial multiplication says that the product of two polynomials is always a polynomial?

That property is called CLOSURE.


C program for matrix multiplication using dynamic memory alllocation?

Poor boy


Are polynomial expressions closed under multiplication?

Yes, because there is no way of multiplying two polynomials to get something that isn't a polynomial.


What is a polynomial multiplication with a quotient of x 3 and a remainder of 2?

To get a quotient and a remainder, you would need to do a division, not a multiplication.


If polynomial is not any number then how will you define a polynomial?

An expression made with constants, variables and exponents, which are combined using addition, subtraction and multiplication, ... but not division.


What is the answer called when 2 or more polynomials are multipiled?

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.


What does it mean for a polynomial to be closed under addition subtraction and multiplication?

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.


Is the factor of polynomials means to rewrite it as multiplication?

Yes. Factoring a polynomial means to separate it into smaller factors, which, when multiplied together, give you the original polynomial.


What is the multiplication property of multiplication?

a*(b + c) = a*b + a*c