answersLogoWhite

0

#include<stdio.h>

#include<conio.h>

#include<process.h>

void read_matrix(int x[10][10],int r,int c)

{

int i,j;

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

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

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

}

void print_matrix(int x[10][10],int r,int c)

{

int i,j;

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

{

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

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

printf("\n");

}

}

void add_matrix(int x[10][10],int y[10][10],int z[10][10],int r,int c)

{

int i,j;

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

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

z[i][j]=x[i][j]+y[i][j];

}

void main()

{

int a[10][10],b[10][10],c[10][10],ra,ca,rb,cb;

clrscr();

printf("Enter order of 2 matrices");

scanf("dd",&ra,&ca,&rb,&cb);

if(ra!=rbca!=cb)

{

printf("addition is not possible");

exit(0);

}

printf("Enter A\n");

printf("Enter B\n");

read_matrix(a,ra,ca);

read_matrix(b,rb,cb);

add_matrix(a,b,c,ra,ca);

print_matrix(c,ra,ca);

getch();

}

User Avatar

Wiki User

15y ago

What else can I help you with?

Related Questions

How do you write a program to performs all airthematic operation between two matrixs using array?

To write a program that performs arithmetic operations between two matrices using arrays, first define two 2D arrays to represent the matrices. Then, create functions for each arithmetic operation (addition, subtraction, multiplication, etc.) that iterate through the elements of the matrices, performing the operation element-wise. Ensure to handle cases where the matrices have different dimensions, as this would affect the validity of the operations. Finally, print the result matrix after each operation.


How do you write a program in C using the fprint and fscan functions?

By using those two functions in your code.


How do you develop a JAVA program that computes matrices?

Matrices can't be "computed" as such; only operations like multiplication, transpose, addition, subtraction, etc., can be done. What can be computed are determinants. If you want to write a program that does operations such as these on matrices, I suggest using a two-dimensional array to store the values in the matrices, and use for-loops to iterate through the values.


Write a C program to find sum of 3 matrices?

matrix


How do you write c program to perform sum of elements of matrix using pointers with functions?

i cant write


Write C program using functions to simulate a Calculator with the basic functions - square root and reciprocal?

trytytytytytytytytrf 6 bcvvtgujhy6


Why we write java program using classes?

Classes are well organised functions in java which help discriminate between two different functions.


What is the importance of functions in a c plus plus program?

Functions are very important in C++, as you can't write the simplest program to print hello without using a function. Overall you can say that function are building blocks of a C++ program. Functions can also be defined by the programmer to reduce program size.


Write a program to illustrate the usage of pointers with arrarys and functions?

* * * * * * * * * * write the c++ program and show me brifily?


How do you add two matrices using Linux shell script?

write ashell script to add awo matrix using array.


Write a c program using dynamic memory allocation function calloc to find sum of two matrices and also print the resultant matrix?

printf("%s",per&gt;50?:"pass",per&lt;50?:"fail");


Write an algorithm for multiplication of two sparse matrices?

how to multiply two sparse matrices