answersLogoWhite

0


Best Answer

include <stdio.h>

int main()

{

int m, n, p, q, c, d, k, sum = 0;

int first[10][10], second[10][10], multiply[10][10];

printf("Enter the number of rows and columns of first matrix\n");

scanf("%d%d", &m, &n);

printf("Enter the elements of first matrix\n");

for ( c = 0 ; c < m ; c++ )

for ( d = 0 ; d < n ; d++ )

scanf("%d", &first[c][d]);

printf("Enter the number of rows and columns of second matrix\n");

scanf("%d%d", &p, &q);

if ( n != p )

printf("Matrices with entered orders can't be multiplied with each other.\n");

else

{

printf("Enter the elements of second matrix\n");

for ( c = 0 ; c < p ; c++ )

for ( d = 0 ; d < q ; d++ )

scanf("%d", &second[c][d]);

for ( c = 0 ; c < m ; c++ )

{

for ( d = 0 ; d < q ; d++ )

{

for ( k = 0 ; k < p ; k++ )

{

sum = sum + first[c][k]*second[k][d];

}

multiply[c][d] = sum;

sum = 0;

}

}

printf("Product of entered matrices:-\n");

for ( c = 0 ; c < m ; c++ )

{

for ( d = 0 ; d < q ; d++ )

printf("%d\t", multiply[c][d]);

printf("\n");

}

}

return 0;

}

User Avatar

Wiki User

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

Wiki User

12y ago

#include<stdio.h>

#include<coin.h>

void main( ){

int a,b,sum;

clrscr( );

print f(enter first number);

scan f("%d",&a);

print f (enter second number)

scan f ("%d",%b);

sum = a+b ;

print f (enter addition )

scan f ("%d,%d",sum):

getch ( );

}

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

02

#include<stdio.h>

03

#include<conio.h>

04

#define max 10

05

void main()

06

{

07

int a[max][max];

08

int a1[max][max];

09

int a2[max][max];

10

int i,j,n,m,k,l,e;

11

clrscr();

12

printf("\nEnter the number of rows of first matrix:");//insertion of first matrix

13

scanf("%d",&n);

14

printf("\nEnter the number of columns of second matrix:");

15

scanf("%d",&m);

16

printf("\nEnter the elements of first matrix:\n");

17

for(i=0;i<n;i++)

18

for(j=0;j<m;j++)

19

scanf("%d",&a[i][j]);

20

printf("\nEnter the number of rows of second matrix:");//insertion of second matrix

21

scanf("%d",&k);

22

printf("\nEnter the number of columns of second matrix:");

23

scanf("%d",&l);

24

printf("\nEnter the elements of second matrix:\n");

25

for(i=0;i<k;i++)

26

for(j=0;j<l;j++)

27

scanf("%d",&a1[i][j]);

28

printf("\n First Matrix you entered:\n");//display of first matrix

29

for(i=0;i<n;i++)

30

{

31

for(j=0;j<m;j++)

32

printf("%d ",a[i][j]);

33

printf("\n");

34

}

35

printf("\n Second Matrix you entered:\n");//display of second matrix

36

for(i=0;i<k;i++)

37

{

38

for(j=0;j<l;j++)

39

printf("%d ",a1[i][j]);

40

printf("\n");

41

}

42

//Multiplication of these two matrices

43

for(i=0;i<n;i++)

44

{

45

for(j=0;j<k;j++)

46

{

47

a2[i][j]=0;

48

for(e=0;e<k;e++)

49

{

50

a2[i][j]=a2[i][j] + (a[i][e] * a1[e][j]);

51

}

52

}

53

}

54

printf("\n Multiplication of matrix is:\n");

55

for(i=0;i<n;i++)

56

{

57

for(j=0;j<l;j++)

58

printf("%d ",a2[i][j]);

59

printf("\n");

60

}

61

getch();

62

}

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

#include <stdio.h>

#include <conio.h>

void multiplication(int x[],int y[]);

void main (void)

{

int a[2][2],b[2][2],i,j,m,n;

clrscr();

printf("Enter 2x2 matrix:\n");

for(i=0;i<2;i++)

for(j=0;j<2;j++)

scanf("%d",&a[i][j]);

printf("\nEnter another 2x2 matrix");

for(m=0;m<2;m++)

for(n=0;n<2;n++)

scanf("%d",&b[i][j]);

multiplication(a,b);

getch();

}

multiplication(int x[],int y[])

{

int i,j,sum;

sum=0;

printf("The multiplication of both the matrices gives:\n");

for(i=0;i<2;i++)

{

for(j=0;j<2;j++)

sum=sum+a[i][j]*b[j][i];

printf("%d\n",sum);

}

}

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

#include<conio.h>

#include<stdio.h>

#include<alloc.h>

void main()

{

int (*a)[10],(*b)[10],(*c)[10],m,n,p,q,i,j,k;

clrscr();

printf("Rows and coloumns of 1 st matrix:");

scanf("%d%d",&m,&n);

printf("Rows and coloumns of 2 nd matrix:");

scanf("%d%d",&p,&q);

if(n!=p)

{

printf("Not possible");

}

else

{

a=(int*)malloc(m*n*sizeof(int));

b=(int*)malloc(p*q*sizeof(int));

c=(int*)malloc(n*p*sizeof(int));

printf("Enter first matrix:");

for(i=0;i<m;i++)

for(j=0;j<n;j++)

scanf("%d",(*(a+i)+j));

printf("Enter second matrix:\n");

for(i=0;i<p;i++)

for(j=0;j<q;j++)

scanf("%d",(*(b+i)+j));

printf("First matrix is:\n");

for(i=0;i<m;i++)

{

printf("\n");

for(j=0;j<n;j++)

printf("%d\t",*(*(a+i)+j));

}

printf("\nSecond matrix is:\n");

for(i=0;i<p;i++)

{

printf("\n");

for(j=0;j<q;j++)

printf("%d\t",*(*(b+i)+j));

}

for(i=0;i<m;i++)

{

for(j=0;j<q;j++)

{

*(*(c+i)+j)=0;

for(k=0;k<n;k++)

*(*(c+i)+j)+=*(*(a+i)+k)*(*(*(b+k)+j));

}

}

printf("\nProduct=\n");

for(i=0;i<m;i++)

{

printf("\n");

for(j=0;j<q;j++)

printf("%d\t",*(*(c+i)+j));

}

}

getch();

}

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

A C-program can be written for matrix addition and multiplication simply by using the two dimensional array function.

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

Write your program and if you are having a problem post it here with a description of the problem you are having.

What you are asking is for someone to do your homework for you.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you write a C program for a matrix multiplication using array?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

C program for matrix multiplication using dynamic memory alllocation?

Poor boy


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


How do you find matrix in c?

using multidimensional array


Is it possible to print matrix without using array?

Yes but why.


Matrix multiplication using mpi?

Check related links


Implementation of a ring of processes using pipes to optimize matrix multiplication?

==Maybe==


Program to count the number of numbers in an array using 8085 microprocessor?

A program which is used to count the number of numbers in an array using a 8085 microprocessor is known as a assembly language program.


C program to sort all elements of a 4x4 matrix?

This type of sorting can b performd by simply transferring all the matrix elements in a single dimension array of 1X16 size and then sorting this array and then transferring the elements back to 4X4 matrix. You can also treat the 4x4 matrix as a simple array using pointers and, thus, not need to transfer from matrix to array and back. Example, using ellipses (...) to simulate indentation for clarity... int matrix[4][4] = {...some values...} int *element; int flag = 1; while (flag == 1) { /* simple bubble sort */ ... flag = 0; ... /* loop from first element to next to last element */ ... for (element = &amp;matrix[0][0]; element &lt; &amp;matrix[3][3]; element ++) { ... ... if (*element &gt; *(element + 1)) { ... ... ... flag = 1; ... ... ... *element ^= *(element + 1); /* exclusive or swap */ ... ... ... *(element + 1) ^= *element; ... ... ... *element ^= *(element + 1); ... ... } ... } }


How do you add two matrices using Linux shell script?

write ashell script to add awo matrix using array.


Sample program array using buffered reader?

system.exit o


How do you write a program to read set of numbers using by an array and display the ascending order of the given input numbers?

To write a C++ program to display the student details using class and array of object.


C plus plus program -matrix multiplication using class?

for(int i=0;i