Академический Документы
Профессиональный Документы
Культура Документы
Assignment No. :
Problem Statement
Program in C to solve the given equation by Gauss Jacobi method.
8x1-3x2+2x3=20
4x1+11x2-x3=33
x1+x2+4x3=9
Algorithm
Variable Description :
Variables
n
i
j
sum
temp
a[10][10]
x[3]
y[3]
Datatype
Integer
Integer
Integer
Float
Float
Float
Float
Float
err
Float
Step
Step
Step
Step
Step
Step
1:
2:
3:
4:
5:
6:
Page No.
Purpose
Stores the number of equations
Loop variable
Loop variable
Stores the sum
Temporary storage
Stores the input given by the user
Stores the result
Calculates and temporarily stores
the result
Stores the error
(ii) sum=0.0
(iii)for (j=0 to n)
(iv) if(j!=i)
(v)sum=sum+a[i][j]*x[j]
(vi)end for loop for j
(vii) temp=(a[i][n+1]-sum)/a[i][i]
(viii)err=fabs(x[i]-temp)
(ix)y[i]=temp
(x)Print x[i]
(xi)end for loop for i
(xii) x[i]=y[i]
(xiii)end do loop
Step 7: while(err>=0.01)
Step 8: for (i=0 to n)
Step 9: Print the result x[i]
Step 10: Stop.
Program Code
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int i,j,n;
float sum,temp,err, a[10][10],x[3],y[3];
clrscr();
printf ("enter the number of equations:");
scanf ("%d",&n);
Page No.
Input/Output
Page No.
Discussion
Page No.
Page No.