Oop 2
Oop 2
#include <math.h>
class Equation{
private:
double a,b,c;
public:
Equation() // constructor
{cout<<"\t\t---------------------\n";
cout<<"\t\t---------------------\n";
cout<<"\t\ta = ";
cin>>a;
cout<<"\t\tb = ";
cin>>b;
cout<<"\t\tc = ";
cin>>c; }
};
void func(Equation n)
{ double disc,proot,nroot;
disc=(n.b*n.b)-(4*n.a*n.c);
proot=(-n.b+sqrt(disc))/(2*n.a);
nroot=(-n.b-sqrt(disc))/(2*n.a);
cout<<"\t\tproot = "<<proot<<'\n';
cout<<"\t\tnroot = "<<nroot<<'\n'; }
void display(Equation n)
{ cout<<"\t\t---------------------\n";
cout<<"\t\t---------------------\n";
func(n);
cout<<"\t\t---------------------\n";}
{ Equation q;
func(q);
display(q);
}
#include <iostream>
#include <math.h>
int a[3][3],b[3][3],c[3][3];
public:
void set_Matrix()
{ cin>>a[i][j];
{ cin>>b[i][j];
} }
void get_Matrix()
{cout<<"------------------\n";
{ cout<<a[i][j]<<'\t'; }
cout<<'\n';
} cout<<"------------------\n";
{ cout<<b[i][j]<<'\t'; }
cout<<'\n';
};
void func(Matrix m)
{cout<<"------------------\n";
cout<<"C = A + B \n";
cout<<"------------------\n";
{ m.c[i][j]=m.a[i][j]+m.b[i][j];
cout<<m.c[i][j]<<'\t'; }
cout<<'\n';
} cout<<"------------------\n";
int main()
{ Matrix mat;
mat.set_Matrix();
mat.get_Matrix();
func(mat);