Sunday, 27 November 2011

C program for Find Matrix Substraction For Using Array


#include<stdio.h>
#include<conio.h>
void main()
{
   int r1,c1,r2,c2,j,i,a[3][3],b[3][3],c[3][3];
   clrscr();
   printf("\n ENTER THE ROW OF MATRIX a =");
   scanf("%d"& r1);
    printf("\n ENTER THE COLUM OF MATRIX a =");
   scanf("%d"& c1);
   printf("\n ENTER THE DATA OF MATRIX a");
   for(i=0;i<r1;i++)
    {
 for(j=0;j<c1;j++)
  {
    scanf("%d",& a[i][j]);
  }
}
   printf("\n ENTER THE ROW OF MATRIX b=");
   scanf("%d", &r2);
   printf("\n ENTER THE COLOM OF MATRIX b=");
   scanf("%d",% c2);
   printf("\n ENTER THE DATA IN MATRIX b=");
   for(i=0;i<r2;i++)
    {
 for(j=0;j<c2;j++)
  {
    scanf("%d",& b[i][j]);
  }
}
   if(r1==r2)&&(c1==c2)
    {
 printf("\n Substraction is Possible and result is following =");
 for(i=0;i<r1;i++)
  {
    for(j=0;j<c1;c++)
 {
   c[i][j] =a[i][j] - b[i][j];
printf("%d",c[i][j]);
 }
printf("\n");
}

else
printf("\n SUBSTRACTION IS NOT POSSIBLE");
getch();

}

No comments:

Post a Comment