PROGRAM
#include<iostream>
using namespace std;
class complex
public:
int a,b;
void get()
cout<<"Enter real numbers: ";
cin>>a;
cout<<"Enter imaginary numbers: ";
cin>>b;
void display()
if(b<0)
cout<<a<<b<<"i"<<endl;
else
cout<<a<<"+"<<b<<"i"<<endl;
complex operator +(complex c)
complex c3;
c3.a=a+c.a;
c3.b=b+c.b;
return c3;
complex operator -(complex c)
complex c3;
c3.a=a-c.a;
c3.b=b-c.b;
return c3;
complex operator *(complex c)
complex c3;
c3.a=a*c.a;
c3.b=b*c.b;
return c3;
complex operator /(complex c)
complex c3;
c3.a=a/c.a;
c3.b=b/c.b;
return c3;
};
int main()
complex c1,c2,c3;
c1.get();
c1.display();
c2.get();
c2.display();
cout<<"The addition of complex numbers is : "<<endl;
c3=c1+c2;
c3.display();
cout<<"The subtraction of complex numbers is : "<<endl;
c3=c1-c2;
c3.display();
cout<<"The multiplication of complex numbers is : "<<endl;
c3=c1*c2;
c3.display();
cout<<"The division of complex numbers is : "<<endl;
c3=c1/c2;
c3.display();
return 0;
OUTPUT
Enter real numbers: 10
Enter imaginary numbers: 20
10+20i
Enter real numbers: 5
Enter imaginary numbers: 4
5+4i
The addition of complex numbers is :
15+24i
The subtraction of complex numbers is :
5+16i
The multiplication of complex numbers is :
50+80i
The division of complex numbers is :
2+5i
--------------------------------
Process exited after 14.12 seconds with return value 0
Press any key to continue . . .