make a C program using cramers rule using 3 variables and 3 equations. I need help why the third variable says it isnt initialized and allow the the determinents to be calculated. also i need help making a menu allowing the user to make a start the program and enter the new variables or to exit the program.
This is what i have so far:
#include
#include
int main (void)
{
int r,c;
double a[3][3],b[3];
double x1a, x2a, x3a, x1, x2, x3, d;
printf("\n Solving for 3 Equations- 3 unknowns\n");
for (r=0; r<3; r++)
{
for (c=0; c<3;c++)
{
printf("Enter a [%d][%d]:" ,r,c);
scanf_s("%lf", &a[r][c]);
}
d=(a[0][0]*a[1][1]*a[2][2])+(a[0][1]*a[1][2]*a[2][0]) +(a[0][2]*a[1][0]*a[2][1])-(a[0][2]*a[1][1]*a[2][0])-(a[0][0]*a[1][2]*a[2][1])-(a[0][1]*a[1][0]*a[2][2]);
x1a=(b[0]*a[1][1]*a[2][2])+(a[0][1]*a[1][2]*b[2])+(a[0][2]*b[1]*a[2][1])-(a[0][2]*a[1][1]*b[2])-(b[0]*a[1][2]*a[2][1])-(a[0][1]*b[1]*a[2][2]);
x2a=(a[0][0]*b[1]*a[2][2])+(b[0]*a[1][2]*a[2][0]) +(a[0][2]*a[1][0]*b[2])-(a[0][2]*b[1]*a[2][0])-(a[0][0]*a[1][2]*b[2])-(b[0]*a[1][0]*a[2][2]);
x3a=(a[0][0]*a[1][1]*b[2])+(a[0][1]*b[1]*a[2][0])+(b[0]*a[1][0]*a[2][1])-(b[0]*a[1][1]*a[2][0])-(a[0][0]*b[1]*a[2][1])-(a[0][1]*a[1][0]*b[2]);
x1=x1a/d; x2=x2a/d; x3=x3a/d;
printf("\n X1=%lf, X2=%lf, X3=%lf\n",x1,x2,x3);
system("pause");
return 0;
}}