can you check this for me please
#include <stdio.h> #include <stdlib.h> #define row 3 #define column 3
void main() { int A[row][column], B[row][column], C[row][column]; int i,j,k; int choice;
for (i=0;i<3;++i) { for (j=0;j<3;++j) { printf("enter values in matrix A"); scanf("%d",&A[i][j]); } }
for (i=0;i<3;++i) { for (j=0;j<3;++j) { printf("enter values in matrix B"); scanf("%d",&B[i][j]); } }
printf("choose one of the following:\n"); printf("1. ADDITION:\n"); printf("2. SUBSTRACTION:\n"); printf("3. MULTIPLICATION:\n");
printf("%d",choice); scanf("%d",&choice);
if(choice==1) { //ADDITION for (i=0;i<3;++i) { for (j=0;j<3;++j) { C[i][j]=A[i][j]+B[i][j]; } } }
else if(choice==2) { //SUBSTRACTION for (i=0;i<3;++i) { for (j=0;j<3;++j) { C[i][j]=A[i][j]+B[i][j]; } } }
else if(choice==3) { //MULTIPLICATION
for (i=0;i<3;++i) { for (j=0;j<3;++j) { C[i][j]=0;
for (k=0;k<3;++k) C[i][j]=C[i][j]+(A[i][j]*B[i][j]); } } }
else if (choice==4) printf("Invalid Operation:\n"); }
//RESULT
/*printf("the resultant matrix is C",C); for (i=0;i<3;++i) { for (j=0;j<3;++j) { C[i][j] printf("C is %s",C); } } system("pause"); }*/
|