Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*--------------------------------------------------------*
- * Main Program *
- * This program solves a system of linear equations *
- * using simple Gaussian elimination method *
- *---------------------------------------------------------*
- * Functions invoked *
- * NIL *
- *---------------------------------------------------------*
- * Subroutines used *
- * GAUSS1 *
- *---------------------------------------------------------*
- * Variables used *
- * n - Number of equations in the system *
- * a - Matrix of coefficients *
- * b - Right side vector *
- * x - Solution vector *
- *---------------------------------------------------------*
- * status - Solution status *
- *---------------------------------------------------------*/
- main()
- {
- int status,n,i,j;
- float a[10][10],b[10],x[10];
- printf("\n SOLUTION BY SIMPLE GAUSS METHOD \n");
- printf("What is the size of the system(n)? \n");
- scanf("%d", &n);
- printf("Input coefficients a(i,j), row-wise, \n");
- printf("one row on each line. \n");
- for(i=1;i<=n;i++)
- for(j=1;j<=n;j++)
- scanf("%f", &a[i][j]);
- printf("\nInput vector b \n");
- for(i=1;i<=n;i++)
- scanf("%f", &b[i]);
- /*obtain solution by simple Gauss elimination method */
- /* call the subroutine gauss1() */
- gauss1(n,a,b,x,&status);
- if(status != 0)
- {
- printf("\nSOLUTION VECTOR X \n");
- printf("/nEnter vector b \n");
- for(i=1;i<=n;i++)
- scanf("%f", &b[i]);
- gauss2(n,a,b,x);
- printf("\n SOLUTION VECTOR X \n");
- printf("\n");
- for(i=1;i<=n;i++)
- printf("\t %f", x[i]);
- printf("\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement