//OPERATIONS ON A MATRIX #include void mat_read(int [20][20],int,int); void mat_add(int [20][20],int [20][20],int [20][20],int,int); void mat_write(int [20][20],int,int); void mat_product(int [20][20],int [20][20],int [20][20],int,int,int); void mat_transpose(int [20][20],int,int); void mat_triangles(int [20][20],int,int); int i,j,k; int mat1[20][20],mat2[20][20],mat3[20][20]; void main() { int r1,c1,r2,c2,r3,c3,opt; clrscr(); //MENU do { printf("1.Add the Arrays\n2.Multiply the arrays\n"); printf("3.Transpose of an array\n4.Lower triangular and Upper triangle\n"); printf("5.Exit\n"); printf("Enter the option\n"); scanf("%d",&opt); switch(opt) { case 1: { //READING MATRICES printf("Enter the row and column of the Matrices\n"); scanf("%d%d",&r1,&c1); clrscr(); printf("Enter the first Matrix"); mat_read(mat1,r1,c1); clrscr(); printf("Enter the Second Matrix\n"); mat_read(mat2,r1,c1); //ADDING mat_add(mat1,mat2,mat3,r1,c1); //SUM clrscr(); printf("Sum Matrix\n"); mat_write(mat3,r1,c1); getch(); clrscr(); break; } case 2: { //READING MATRICES printf("Enter the row and column of First Matrix\n"); scanf("%d%d",&r1,&c1); printf("Enter the row and column of Second Matrix\n"); scanf("%d%d",&r2,&c2); if(c1!=r2) printf("Multiplication not possible!\n"); else { clrscr(); printf("Enter the First Matrix\n"); mat_read(mat1,r1,c1); clrscr(); printf("Enter the Second Matrix\n"); mat_read(mat2,r2,c2); //MULTIPLICATION mat_product(mat1,mat2,mat3,r1,c1,c2); clrscr(); printf("The Product Matrix is\n"); mat_write(mat3,r1,c2); } getch(); clrscr(); break; } case 3: { //READING MATRIX printf("Enter the number of rows and columns of the Matrix\n"); scanf("%d%d",&r1,&c1); clrscr(); mat_read(mat1,r1,c1); clrscr(); printf("Given Matrix\n"); mat_write(mat1,r1,c1); printf("\n"); //TRANSPOSE printf("Transpose is\n"); mat_transpose(mat1,r1,c1); getch(); clrscr(); break; } case 4: { //READING MATRIX printf("Enter the number of rows and columns of the Matrix\n"); scanf("%d%d",&r1,&c1); if(r1!=c1) printf("Square Matrix Required!"); else { clrscr(); printf("Enter the Matrix\n"); mat_read(mat1,r1,c1); //LOWER TRIANGLE //UPPER TRIANGLE mat_triangles(mat1,r1,c1); } getch(); clrscr(); break; } case 5: exit(); default: printf("Invalid Entry!\n"); getch(); clrscr(); } }while(opt!=5); getch(); } void mat_read(int mat[20][20],int row,int col) { for(i=0;i