This is a simple C language program that calculates solution of n-linear equations using Non-pivotal Gauss Elimination method. It uses upper triangular matrix to do so, for solution using lower triangular matrix visit here.

#include<stdio.h> #include<conio.h> float matrix[10][10], m, temp[10]; int i, j, k, n; void upper_triangularization() { for (i=0; i<n-1; i++) for (j=i+1; j<n; j++) { m = matrix[j][i]/matrix[i][i]; for (k=0; k<n+1; k++) { matrix[j][k] = matrix[j][k]-(m*matrix[i][k]); } } } //upper_traingulisation void back_subsitution() { for (i=n-1; i>=0; i--) { m = matrix[i][n]; for (j=n-1; j>i; j--) m = m - temp[n-j] * matrix[i][j]; temp[n-i] = m/matrix[i][i]; printf("\n x%d => %f", i+1, temp[n-i]); } } // back_subsitution void main() { printf("Enter number. of variables :: "); scanf("%d", &n); printf("Enter the augmented matrix: \n"); for (i=0; i<n; i++) for (j=0; j<n+1; j++) scanf("%f", &matrix[i][j]); upper_triangularization(); printf("The upper traingular matrix is : \n"); for (i=0; i<n; i++) { for (j=0; j<n+1; j++) printf("%f \t", matrix[i][j]); printf("\n"); } printf("The required result is : \n"); back_subsitution(); getch(); } // main

Latest posts by Abhishek Gupta (see all)

- Laravel Custom Exception Handlers - March 28, 2019
- Customizing Laravel validation JSON message format - March 20, 2019
- Time killer and addictive Google Games - March 19, 2019

oh my god that’s finally done thanks man..!! none of the websites helped me properly… but your one is correct