Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- void main()
- {
- int a[3][4],i,j,temp,x,y,z;
- printf("enter the coefficients of the 3 equations of type ax+by+cz=d to find values of x,y,z\n");
- for(i=0;i<3;i++)
- {
- printf("enter the values of a,b,c,d for equation:%d\n",i+1);
- for(j=0;j<4;j++)
- {
- scanf("%d",&a[i][j]);
- }
- }
- for(i=1;i<3;i++)
- {
- temp=a[i][0];
- for(j=0;j<4;j++)
- a[i][j]=(a[0][0]*a[i][j])-(temp*a[0][j]);
- }
- temp=a[2][1];
- for(j=0;j<4;j++)
- a[2][j]=(a[1][1]*a[2][j])-(temp*a[1][j]);
- printf("the upper triangular matrix is\n");
- for(i=0;i<3;i++)
- {
- for(j=0;j<4;j++)
- {
- printf("%d\t",a[i][j]);
- }
- printf("\n");
- }
- z=a[2][3]/a[2][2];
- y=(a[1][3]-a[1][2]*z)/a[1][1];
- x=((a[0][3]-a[0][2]*z)-(a[0][1]*y))/a[0][0];
- printf("the values are x=%d \ny=%d \nz=%d \n",x,y,z);
- }
Advertisement
Add Comment
Please, Sign In to add comment