Input : Enter A matrix elements
10 20 30
40 50 60
70 80 90
Enter B matrix elements
10 20 30
40 50 60
70 80 90
Output : C matrix elements
20 40 60
80 100 120
140 160 180
D matrix elements
0 0 0
0 0 0
0 0 0
#include <stdio.h>
#define SIZE 3
void main()
{
int A[SIZE] [SIZE];
int B[SIZE] [SIZE];
int C[SIZE] [SIZE]; //C is the resultant matrix
int D[SIZE] [SIZE];
int row, col;
printf("Enter A matrix elements\n");
for(row=0; row < SIZE; row++){
for(col=0; col <SIZE; col++){
scanf("%d", &A[row][col]);
}
}
printf("Enter B matrix elements\n");
for(row=0; row < SIZE; row++){
for(col=0; col <SIZE; col++){
scanf("%d", &B[row][col]);
}
}
printf("C matrix elements\n");
for(row=0; row < SIZE; row++){
for(col=0; col <SIZE; col++){
C[row] [col]=A[row] [col]+B[row][col];
printf("%d\t", C[row][col]);
}
printf("\n");
}
printf("D matrix elements\n");
for(row=0; row < SIZE; row++){
for(col=0; col <SIZE; col++){
D[row] [col]=A[row] [col]-B[row][col];
printf("%d\t", D[row][col]);
}
printf("\n");
}
}
10 20 30
40 50 60
70 80 90
Enter B matrix elements
10 20 30
40 50 60
70 80 90
Output : C matrix elements
20 40 60
80 100 120
140 160 180
D matrix elements
0 0 0
0 0 0
0 0 0
#include <stdio.h>
#define SIZE 3
void main()
{
int A[SIZE] [SIZE];
int B[SIZE] [SIZE];
int C[SIZE] [SIZE]; //C is the resultant matrix
int D[SIZE] [SIZE];
int row, col;
printf("Enter A matrix elements\n");
for(row=0; row < SIZE; row++){
for(col=0; col <SIZE; col++){
scanf("%d", &A[row][col]);
}
}
printf("Enter B matrix elements\n");
for(row=0; row < SIZE; row++){
for(col=0; col <SIZE; col++){
scanf("%d", &B[row][col]);
}
}
printf("C matrix elements\n");
for(row=0; row < SIZE; row++){
for(col=0; col <SIZE; col++){
C[row] [col]=A[row] [col]+B[row][col];
printf("%d\t", C[row][col]);
}
printf("\n");
}
printf("D matrix elements\n");
for(row=0; row < SIZE; row++){
for(col=0; col <SIZE; col++){
D[row] [col]=A[row] [col]-B[row][col];
printf("%d\t", D[row][col]);
}
printf("\n");
}
}
একটি মন্তব্য পোস্ট করুন