program crashes.. anything wrong??

I made a program on Cramer's Rule but after taking input it just crashes ... Please Help if u can find out whats wrong with my code...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include<stdio.h>
#include<conio.h>
int det(int A[3][4]);
int swapper(int A[3][4],int col);
main()
{
      int A[3][4],i,j;
      printf("Enter Coefficients of all equations:\nfor example:\n\tfor\t 25x + 8y + 9z = 24\nYou will enter   25    8    9    24:\n\n\n");
      for (i=0;i<3;i++)
      {
          printf("Enter the Coefficients of Equation # %d:",i+1);
          for(j=0;j<4;j++)
          {
            scanf("%d",&A[i][j]);
          }
      }
      int O = det(A);
      int X = swapper(A,0);
      int Y = swapper(A,1);
      int Z = swapper(A,2);
      printf("\n\nThe Value of X = %0.2f",X/O);
      printf("\nThe Value of Y = %0.2f",Y/O);
      printf("\nThe Value of Z = %0.2f",Z/O);
      getch();
}

int det(int A[3][4])
{
    int i,j,x,y,L[4],u=0,X[3],g=0;
    for(i=0;i<3;i++)
    {
       j=0;
       for(x=0;x<3;x++)
       {
        for(y=0;y<3;y++)
        {
          if(x!=j&&y!=i)
          {
            L[u]=A[x][y];
            u++;
          }
        }
        
       }
       X[g]=A[j][i]*((L[0]*L[3])-(L[1]*L[2]));
        g++;
        u=0;
    }
    return (X[0]-X[1]+X[2]);
}

int swapper(int A[3][4],int col)
{
    int x;
    for(x=0;x<3;x++)
    {
      A[x][col]=A[x][3];
    }
    int c = det(A);
    return c;
}


AND THANKS IN ADVANCE!!!!!!!!!
You've forgotten 'int' before main( line 5 )
It did not help!!!
i think if there is any problem with using a function into another function? (line 59)
If det(A) is zero you'll be dividing by zero.

What inputs are you using to make it crash?
I couldn't reproduce it. ┬┐where does the crash happen?

Your algorithm is incorrect as you are overwriting the matrix in the `swapper', then Z will always be 0.

Also printf("\n\nThe Value of X = %0.2f",((double)X)/O); integer division returns an integer.
I think there is problem with your algorithm
Suppose you are entering

a1 b1 c1 d1
a2 b2 c2 d2
a3 b3 c3 d3

In first step when you replace

a1
a2
a3

with
d1
d2
d3

and in second step when you are replacing { b2 b2 b3} with {d1 d2 d3}
a1 a2 a3 is still replaced with d1 d2 d3
So et the end your matrix is

d1 d1 d1 d1
d2 d2 d2 d2
d3 d3 d3 d3
Can you make the corrections for me i will very grateful
Thanks sir that was very helpful ... i fixed that problem you just pointed out by making a backup of values and then replacing it before returning value ... Thanks again Sir TTT
Topic archived. No new replies allowed.