#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();
}
By using those two functions in your code.
write a vb program to find the magic square
Using parameters argc and argv, and library functions fopen, fprintf, fclose
Write and run a client and a server program in C-language using UDP
write a c++ program to convert binary number to decimal number by using while statement
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.
By using those two functions in your code.
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.
i cant write
trytytytytytytytytrf 6 bcvvtgujhy6
Classes are well organised functions in java which help discriminate between two different functions.
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 ashell script to add awo matrix using array.
printf("%s",per>50?:"pass",per<50?:"fail");
write a sample program using asp.net explaining all the syntax and semantics of the program
C programs do not function without functions.
write a vb program to find the magic square