C++ program to find the difference of elements in a matrix

// Difference of elements in a matrix c++

#include<stdio.h>
#include<conio.h>
void main()
{
                clrscr();
                int r,c,a[50][50],b[50][50],s[50][50],i,j;
                printf("Enter the row value and cloum value\n");
                scanf("%d%d",&r,&c);
                printf("Enter the elements of first matrics\n");
                for(i=0;i<r;i++)
                {
                                for(j=0;j<c;j++)
                                {
                                scanf("%d",&a[i][j]);
                                }
                }
                printf("Enter the elements of second matrics\n");
                for(i=0;i<r;i++)
                {
                                for(j=0;j<c;j++)
                                {
                                                scanf("%d",&b[i][j]);
                                }
                }
                for(i=0;i<r;i++)
                {
                                for(j=0;j<c;j++)
                                {
                                                s[i][j]=a[i][j]-b[i][j];
                                }
                }
                printf("Difference of matrics\n");
                for(i=0;i<r;i++)
                {
                                for(j=0;j<c;j++)
                                {
                                                printf("%d ",s[i][j]);
                                }
                                printf("\n");
                }
                getch();
}

Output


No comments: