#include<stdio.h>
void main()
{
int i,j,a[3][4];
float det,detx,dety,detz,x,y,z;
printf("a1x+b1y+cz=d1\na2x+b2y+c2z=d2\na3x+b3y+c3z=d3\n");
printf("enter value of a1,b1,c1,d1,a2,b2,c2,d2,a3,b3,c3,d3");
for(i=0;i<3;i++)
{
for(j=0;j<4;j++)
{
scanf("%d",&a[i][j]);
}
}
det=a[0][0]*a[1][1]*a[2][2]-a[0][0]*a[2][1]*a[1][2]-a[0][1]*a[1][0]*a[2][2]+a[0][1]*a[2][0]*a[1][2]+a[0][2]*a[1][0]*a[2][1]-a[0][2]*a[2][0]*a[1][1];
detx=a[0][3]*a[1][1]*a[2][2]-a[0][3]*a[2][1]*a[1][2]-a[0][1]*a[1][3]*a[2][2]+a[0][1]*a[2][3]*a[1][2]+a[0][2]*a[1][3]*a[2][1]-a[0][2]*a[2][3]*a[1][1];
dety=a[0][0]*a[1][3]*a[2][2]-a[0][0]*a[2][3]*a[1][2]-a[0][3]*a[1][0]*a[2][2]+a[0][3]*a[2][0]*a[1][2]+a[0][2]*a[1][0]*a[2][3]-a[0][2]*a[2][0]*a[1][3];
detz=a[0][0]*a[1][1]*a[2][3]-a[0][0]*a[2][1]*a[1][3]-a[0][1]*a[1][0]*a[2][3]+a[0][1]*a[2][0]*a[1][3]+a[0][3]*a[1][0]*a[2][1]-a[0][3]*a[2][0]*a[1][1];
if(det==0&&detx==0&&dety==0&&detz==0)
{
printf("there are infinite solution");
}
else if(det!=0)
{
x=detx/det;
y=dety/det;
z=detz/det;
printf("there is a unique solution\n");
printf("x=%f\n",x);
printf("y=%f\n",y);
printf("z=%f\n",z);
}
else
{
printf("the system is incosistent and has no solution");
}
}
void main()
{
int i,j,a[3][4];
float det,detx,dety,detz,x,y,z;
printf("a1x+b1y+cz=d1\na2x+b2y+c2z=d2\na3x+b3y+c3z=d3\n");
printf("enter value of a1,b1,c1,d1,a2,b2,c2,d2,a3,b3,c3,d3");
for(i=0;i<3;i++)
{
for(j=0;j<4;j++)
{
scanf("%d",&a[i][j]);
}
}
det=a[0][0]*a[1][1]*a[2][2]-a[0][0]*a[2][1]*a[1][2]-a[0][1]*a[1][0]*a[2][2]+a[0][1]*a[2][0]*a[1][2]+a[0][2]*a[1][0]*a[2][1]-a[0][2]*a[2][0]*a[1][1];
detx=a[0][3]*a[1][1]*a[2][2]-a[0][3]*a[2][1]*a[1][2]-a[0][1]*a[1][3]*a[2][2]+a[0][1]*a[2][3]*a[1][2]+a[0][2]*a[1][3]*a[2][1]-a[0][2]*a[2][3]*a[1][1];
dety=a[0][0]*a[1][3]*a[2][2]-a[0][0]*a[2][3]*a[1][2]-a[0][3]*a[1][0]*a[2][2]+a[0][3]*a[2][0]*a[1][2]+a[0][2]*a[1][0]*a[2][3]-a[0][2]*a[2][0]*a[1][3];
detz=a[0][0]*a[1][1]*a[2][3]-a[0][0]*a[2][1]*a[1][3]-a[0][1]*a[1][0]*a[2][3]+a[0][1]*a[2][0]*a[1][3]+a[0][3]*a[1][0]*a[2][1]-a[0][3]*a[2][0]*a[1][1];
if(det==0&&detx==0&&dety==0&&detz==0)
{
printf("there are infinite solution");
}
else if(det!=0)
{
x=detx/det;
y=dety/det;
z=detz/det;
printf("there is a unique solution\n");
printf("x=%f\n",x);
printf("y=%f\n",y);
printf("z=%f\n",z);
}
else
{
printf("the system is incosistent and has no solution");
}
}
No comments:
Post a Comment