C Program To find the difference of two Matrices

by Nideesh C on April 18, 2011 · 0 comments

in C Programming




#include<stdio.h>
void main()
{
int A[5][5], B[5][5], C[5][5], i, j, m, n;
clrscr();
printf(“nnt ENTER A ORDER OF THE MATRICES M,N…: “);
scanf(“%d,%d”, &m, &n);
printf(“nnt ENTER THE ELEMENTS OF THE FIRST MATRIX..:nn”);
for(i=1;i<=m;i++)
{
for(j=1;j<=n;j++)
{
gotoxy(25+j*4,12+i*2);
scanf(“%d”,&A[i][j]);
}
printf(“n”);
}
printf(“nt ENTER THE ELEMENTS OF THE SECOND MATRIX..:nn”);
for(i=1;i<=m;i++)
{
for(j=1;j<=n;j++)
{
gotoxy(25+j*4,18+m+i*2);
scanf(“%d”,&B[i][j]);
}
printf(“n”);
}
for(i=1;i<=m;i++)
for(j=1;j<=n;j++)
C[i][j] = A[i][j] – B[i][j];
printf(“nt THE DIFFERENCE OF TWO MATRICES IS…:nnttt “);
for(i=1;i<=m;i++)
{
for(j=1;j<=n;j++)
printf(” %d”,C[i][j]);
printf(“nnttt “);
}
getch();
}

Not Satisfied ? Just search & get the result

Related Posts Plugin for WordPress, Blogger...
Be Sociable, Share!

Related posts:

  1. C Program To multiply two Matrices
  2. C program to accept two matrices and find the sum and difference of the matrices
  3. C Program to accept two matrices and check if they are equal
  4. C program to read two matrices A (MxN) and B(MxN) and perform addition OR subtraction of A and B. Find the trace of the resultant matrix. Output the given matrix, their sum or Differences and the trace.
  5. C Program – Find the transpose of a Matrix

Leave a Comment

Previous post:

Next post: