//Sample Program for Complex Numbers#include
<iostream.h>
class complex {
int real, imag;
public:
complex ();
void read ();
void write ();
int iszero ();
void add (complex C1, complex C2);
};
complex::complex () {
real = imag = 0;
}
void complex::read () {
cin >> real >> imag;
}
void complex::write () {
cout << real <<" + "<< imag << 'i';
}
int complex::iszero () {
return (real ==0 && imag == 0)
}
void complex::add (complex C1, complex C2) {
real = C1.real + c2.real;
imag = C1.imag + c2.imag;
}
main () {
complex C,D,S;
if (C.iszero)
cout << "value is zero\n";
else
cout << "value is not zero\n";
C.write ();
cout << '\n';
C.read ();
if (C.iszero)
cout << "value is zero\n";
else
cout << "value is not zero\n";
C.write ();
cout << '\n';
D.read ();
S.add(C,D);
S.write ();
cout << '\n';
}