Create a C Code program that solves the following set of non
Create a C Code program that solves the following set of nonlinear equations by the Gauss-Seidel method.
27x +ex cos y - 0.12 z = 3
-0.2 x2+37 y +3 x z = 6
x2 - 0.2 y sin x + 29 z = -4
 Start with an initial guess of x = y = z = 1
 .
Solution
#include<stdio.h>
 #include<math.h>
 main()
 {
    int totalVariables;
    printf(\"How many varables in equation: \");
    scanf(\"%d\",&totalVariables);
 float data[totalVariables][totalVariables+1],resData[totalVariables], err, maxNumber,t,s,e;
 int i,j,r,maxIter;
 for(i=0;i<totalVariables;i++) resData[i]=0;
 puts(\" Eneter the elements of augmented matrix\ \");
 for(i=0;i<totalVariables;i++)
 {
 for(j=0;j<totalVariables+1;j++)
 {
 scanf(\"%f\",&data[i][j]);
 }
 }
 printf(\" Eneter the msx error and number of iteration: \");
 scanf(\"%f%d\",&err,&maxIter);
 printf(\"Iteration \\t data[1] \\t data[2] \ \");
 for(r=1;r<=maxIter;r++)
 {
 maxNumber=0;
 for(i=0;i<totalVariables;i++)
 {
 s=0;
 for(j=0;j<totalVariables;j++)
 if(j!=i) s+=data[i][j]*resData[j];
 t=(data[i][totalVariables]-s)/data[i][i];
 e=fabs(resData[i]-t);
 resData[i]=t;
 }
 printf(\" %5d\\t\",r);
 for(i=0;i<totalVariables;i++)
 printf(\" %9.4f\\t\",resData[i]);
 printf(\"\ \");
 if(maxNumber<err)
 {
 printf(\" Completed in %3d iteration\ \", r);
 for(i=0;i<totalVariables;i++)
 printf(\"resData[%3d]=%7.4f\ \", i+1,resData[i]);
 return 0;
 }
 
 }
 }


