week 8
week 8
}
for (int i = 0; i < r; i++) {
for (int j = 0; j < c; j++) {
printf(" %d", matrix[i][j]);
}
printf("\n");
}
}
return 0;
}
3) You are given two matrices, AA and BB, each of size r×cr×c. Your task is to
determine whether the two matrices are equal or not.
ANALYSIS:
Input : int a[10][10],i,j,r,c,
Logic : if(a[i][j] != b[i][j]){
printf("Not Equal");
Output : Print "Equal" if the two matrices are equal.
C-PROGRAM:
#include<stdio.h>
#include<stdlib.h>
int main()
{
int a[10][10],i,j,r,c,b[10][10];
scanf("%d%d", &r,&c);
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
scanf("%d", &a[i][j]);
}
}
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++)
{
if(a[i][j] != b[i][j]){
printf("Not Equal");
exit(0);
}
}
}
printf("Equal");
}