answersLogoWhite

0

#include<stdio.h>

#include<conio.h>

#include<math.h>

void main()

{

int a[4][4],b[4][4],c[4][4],i,j;

printf("enter the elements of matrix a");

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

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

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

printf("the first matrix is");

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

{

printf("\n");

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

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

}

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

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

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

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

printf("the second matrix is");

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

{

printf("\n");

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

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

}

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

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

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

printf("the addition of matrix is");

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

{

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

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

printf("\n");

}

getch();

} Answer by sujit saxena:

#include<stdio.h>

#include<conio.h>

void main()

{

int a[20][20],b[20][20],c[20][20],i,j,r1,r2,c1,c2,ta,tb;

clrscr();

printf("Enter order of Matrix A: ");

scanf("d",&r1,&c1);

ta=r1*c1;

printf("\nEnter %d elements=",ta);

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

{

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

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

}

printf("\nEnter order of Matrix B: ");

scanf("d",&r2,&c2);

tb=r2*c2;

if(r1==r2 && c1==c2)

{

printf("\nEnter %d elements=",tb);

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

{

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

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

}

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

{

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

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

}

printf("\nSum of matrix is\n");

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

{

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

{

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

}

printf("\n");

}

}

else

printf("\nAdddition is not possible pls enter same matrices");

getch();

}

User Avatar

Wiki User

13y 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.


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.


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 a sample program using ASPNET explaining all the syntax and semantics of the program?

write a sample program using asp.net explaining all the syntax and semantics of the program


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

C programs do not function without functions.


How do you write Square program using vb?

write a vb program to find the magic square