1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
#include <iostream>
#include <conio.h>
using namespace std;
class complex
{
float num1,num2,num3,num4;
public:
complex()
{
num1=0;num2=0;num3=0;num4=4;
}
complex(float,float,float,float);
void add();
void subtract( );
void multiply();
void print();
};
complex::complex(float a,float b,float c,float d)
{
num1=a;
num2=b;
num3=c;
num4=d;
}
void complex::add()
{
num1+num3;
cout<<" + i";
num2+num4;
}
void complex::subtract()
{
num3-num1;
cout<<" + i";
num4-num2;
}
void complex::multiply()
{
num1*num3;
cout<<" + i";
num1*num4;
cout<<" + i";
num2*num3;
cout<<"-";
num2*num4;
}
void complex:: print()
{
cout<<"The addition is :"<<endl;
cout<<add()<<endl;
cout<<"The subtraction is :"<<endl;
cout<<subtract()<<endl;
cout<<"the multiplication is :"<<endl;
cout<<multiply()<<endl;
}
int main()
{
float a,b,c,d,e,f,g,h=0;
cout<<"please enter the first real number. "<<endl;
cin>>a;
cout<<"please enter the second complex number ."<<endl;
cin>>b;
cout<<"please enter the 3rd real number. "<<endl;
cin>>c;
cout<<"please enter the 4th complex number ."<<endl;
cin>>d;
complex i (a,b,c,d);
i.add();
i.subtract();
i.multiply();
i.print();
getch();
return 0;
}
|