answersLogoWhite

0


Best Answer

#include<stdio.h>

#include<conio.h>

main()

{ int a[10][10],b[10][10],c[10][10],m,n,i,j,p,q,op;

printf("enter the order of matrix a:n");

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

printf("enter the %d elements of a\n",m*);

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

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

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

printf("enter the order of matrix b:n");

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

printf("enter the %d elements of b\n",p*q);

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

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

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

printf("enter the option\n");

scanf("%d",&option);

switch(op)

{ case '+' : if(m==p&&n==q)

printf("the resultant matrix c is:\n");

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

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

c[i][j]=a[i][j]+b[i][j];

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

printf("\n");

break;

case '/' : if(n==p)

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

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

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

}

}

c[i][j]=0;

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

c[i][j]=c[i][j]+a[i][p]*b[p][j]:

}

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

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

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

{printf("%d\t",c[i][j]);

}

}

printf("\n");

getch();

}

User Avatar

Wiki User

9y ago
This answer is:
User Avatar

Add your answer:

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

2x2 matrix multiplication program in 8085 processor?

how to write a program for matrix multiplication in microprocesspr


Write a c program for matrix addition using function?

#include&lt;


How do you write a program of matrix multiplication in a simple way?

you can write by two ways 1 by giving the size of array at declaration 2 by checking condition


Write a program to multiply 33 matrix.?

write a program to multily 3*3 matrix.


Write a program using iostreams to take as input two multi-dimensional arrays and print their sum as output Matrix Addition in Matrix format?

http://www.assignmentsclub.com/


How do you Write A program in c language for checking a diagonal matrix?

Write a program in c++ that take input in a integer matrix of size 4*4 and find out if the entered matrix is diagonal or not.


How do you Write a C program for matrix addition?

for (i=0; i&lt;IMAX; i++) for (j=0; j&lt;JMAX; j++) c[i,j] = a[i,j] + b[i,j];


A c program to square matrix?

A C program to square matrix is a math problem. In the math problem you write down all the outer boundary values of matrix in a circle, then write down the inner value.


Write a c program to find eigenvalue of a matrix?

Yes, do write. That's what you always have to do when you have got a homework-program.


How do you write a java program to find the transpose of the matrix for the given elements?

You basically write a nested for loop (one for within another one), to copy the elements of the matrix to a new matrix.


How do you write a java program to find the ad joint of a matrix?

bgfygfrhjyuyhh


Write a program to print the sum of a sparse matrix?

This is a directive, not a question.