Hello everyone, I am Arkaprava, a college student.....I am having huge problem regarding running the following program....please help me out. It has no compilation error but during runtime, it is giving rise to strange values.....please debug it....

Thanks in advance....

---------------

@rk@

Thanks in advance....

Code:

#include<stdio.h> #include<conio.h> #include<process.h> #define size 3 int cofactor(int a[size][size], int m, int n) { int b[size-1][size-1]; int i,j; if((m>size-1)||(n>size-1)) { printf("\nERROR!.....Check the value of m,n\n"); exit(0); } for(i=0;i<m;i++) { for(j=0;j<n;j++) { b[i][j]=a[i][j]; } } for(i=m+1;i<size;i++) { for(j=n+1;j<size;j++) { b[i-1][j-1]=a[i][j]; } } for(i=0;i<m;i++) { for(j=n+1;j<size;j++) { b[i][j-1]=a[i][j]; } } for(i=m+1;i<size;i++) { for(j=0;j<n;j++) { b[i-1][j]=a[i][j]; } } return b[size-1][size-1]; } void main() { int a[size][size], b[size-1][size-1]; int i,j,m,n; printf("Enter row index="); scanf("%d", &m); printf("Enter column index="); scanf("%d", &n); for(i=0;i<size;i++) { for(j=0;j<size;j++) { printf("Enter the element a[%d][%d]=", i, j); scanf("%d", &a[i][j]); } } printf("\nThe matrix is\n"); for(i=0;i<size;i++) { for(j=0;j<size;j++) { printf("%d\t", a[i][j]); } printf("\n"); } getch(); b[size-1][size-1]=cofactor(a,m,n); printf("\nCofactor of a[%d][%d] is\n", m,n); for(i=0;i<size-1;i++) { for(j=0;j<size-1;j++) { printf("%d\t", b[i][j]); } printf("\n"); } getch(); }

@rk@