# C++ program to solve Upper-Triangular Matrix transform and solving Using Back-Substitution

Consider a set of equations in a matrix form Ax=b, where A is a upper triangular matrix with non-zero diagonal elements. The equation is re-written in full matrix form as

Solved using the following algorithm

Example: Consider a system with the given row-echelon form for its augmented matrix.

The equations for this system are

x − 2y + z = 4
y + 6z = −1
z = 2

The last equation says z = 2. Substitute this into the second equation to get

y + 6(2) = −1
y = −13

Now substitute z = 2 and y = –13 into the first equation to get

x−2(−13)+(2)=4
x=−24

Thus the solution is x = –24, y = –13, and z = 2.

### Example: C++ program to solve Upper-Triangular Matrix transform and solving Using Back-Substitution

#### Output

Enter the size Of Matrix

3
Enter the matrix by rows
x
1
x
-2
x
1
x
0
x
1
x
6
x
0
x
0
x
1
Enter the Element into b =
4
Enter the Element into b =
-1
Enter the Element into b =
2
1    -2     1
0    1      6
0    0      1
Solution of Ax=b is X = -24
Solution of Ax=b is X = -13
Solution of Ax=b is X = 2