#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();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int a[2][2],b[2][2],m,n,i,j,c[8][8],p,q,k,h;
clrscr();
printf("Enter the size of matrix1\n");
scanf("d",&m,&n);
printf("Enter the matrix1\n");
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
scanf("%d",&a[i][j]);
}
}
printf("Enter the size of matrix2\n");
scanf("d",&p,&q);
printf("Enter the matrix2\n");
for(i=0;i<p;i++)
{
for(j=0;j<q;j++)
{
scanf("%d",&b[i][j]);
}
}
for(i=0;i<k;i++)
{
for(j=0;j<h;j++)
{
c[i][j]=a[i][j]+b[i][j];
}
}
printf("Added matrix is");
for(i=0;i<k;i++)
{
for(j=0;j<h;j++)
{
printf("%d",c[i][j]);
}
}
getch();
}
#include<stdio.h>
int main()
{
const int M=3, N=3;
int c[M][N], d[M][N],e[M][N];
int i,j;
printf("nEnter the elements of martices c and d row-wise");
printf("nIn the format c[i][j], d[i][j]...n");
for(i=0; i<M; i++)
for(j=0; i<N; j++)
scanf("%d,%d",&c[i][j],&[i][j]);
printf("nThe matrix c as entered is ... n");
print_matrix (c);
printf("nThe matrix d as entered is...n");
print_matrix(d);
for(i=o;i<M;i++)
for(j=0;j<N;j++)
e[i][j] = c[i][j] + d[i][j];
printf("nThe matrix e as a sum of c and d is ... n");
print_matrix(e);
return 0;
}
print_matrix(int x[][])
{
int i,j;
for(i=0;i<m;i++){
for(j=o;j<N;j++)
print("%4d", x[i][j]);
printf("n");
}
#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();
}
Write a program to add two matrices using the concept of arrays.
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
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");
C programs do not function without functions.
write a sample program using asp.net explaining all the syntax and semantics of the program
Which one of those matrices is more comfortable to sleep on?
i love u darling