C++ PROGRAM TO SOLVE EQUATIONS OF 3 VARIABLES

/* A C++ PROGRAM TO SOLVE EQUATIONS OF 3 VARIABLES
BY MOHIT RAJPUT */


#include
#include

class equ
{
private:

float a,b,c,d;
float x,y,z;

public:
void input()
{
cout<<"\nEnter coefficients a,b,c & d=";
cin>>a>>b>>c>>d;
}

void print()
{
cout<}

void calc(equ p,equ q,equ r)
{
q.b=p.a*q.b-q.a*p.b;
q.c=p.a*q.c-q.a*p.c;
q.d=p.a*q.d-q.a*p.d;

r.b=p.a*r.b-r.a*p.b;
r.c=p.a*r.c-r.a*p.c;
r.d=p.a*r.d-r.a*p.d;

z=(r.b*q.d-q.b*r.d)/(r.b*q.c-q.b*r.c);
y=(q.d-q.c*z)/q.b;
x=(p.d-p.c*z-p.b*y)/p.a;
}

void result()
{
cout<<"\nx="<cout<<"\ny="<cout<<"\nz="<}
};

void main()
{
clrscr();
cout<<"\n\t\t\tGAUSS ELIMINATION METHOD\n";
cout<<"--------------------------------------------------------------------------------";
cout<<"\nEquation format is: ax+by+cz=d";
equ p,q,r,w;
p.input();
q.input();
r.input();
cout<<"\nEQUATIONS ARE:\n";
p.print();
q.print();
r.print();
w.calc(p,q,r);
cout<<"\nSOLUTION IS:\n";
w.result();
getch();
}

Popular Posts