@Ananth_subbu
Nothing here yet.
Nothing here yet.
No blogs yet.
#include <stdio.h> #include <conio.h> void main() { int mainMat[10][10], minorMat[10][10], i, j, x, y, r, c, num1=0,num2=0; clrscr(); printf("This program can find a minor matrix based on any element of a given matrix. \n"); printf("Please enter the number of rows and columns of the main matrix\n"); scanf("%d%d", &r, &c); for(i=0; i<r; i++) for(j=0; j<c; j++) { mainMat[i][j] = 0; } for(i=0; i<r; i++) for(j=0; j<c; j++) { minorMat[i][j] = 0; } printf("Now enter the following elements for the matrix: \n"); for(i=0; i<r; i++) for(j=0; j<c; j++) { printf("Enter the element a%d%d: ", i+1, j+1); scanf("%d", &mainMat[i][j]); } // for(i=0; i<r; i++) // for(j=0; j<c; j++) // { // printf("mainMat[%d][%d] = [%d]",i,j,mainMat[i][j]); // printf("\n"); // } printf("\nNow enter the coordinates of the element in the matrix you want to base the minor matrix upon: "); scanf("%d%d", &x ,&y); printf("x=%d,y=%d",x,y); for(i=0; i<r; i++) { num2=0; if(i == x-1) { printf("i=%d, x-1=%d",i,x-1); continue; } for(j=0; j<c; j++) { if (j == y-1) { continue; } else { minorMat[num1][num2] = mainMat[i][j]; num2++; } } num1++; } printf("num1=%d, num2= %d",num1,num2); printf("\nOutput Matrix:\n\n"); for(i=0; i<num1; i++){ for(j=0; j<num2; j++) { printf("minorMat[%d][%d] = %d ",i,j,minorMat[i][j]); printf("\n\n"); } } getch(); }