In C + + is a class dedicated to work with complex numbers, which is part of its standard library, defined in the library complex. Using this will make you work easier because the class provides a set of functions to perform arithmetic operations on this set of numbers, in addition to the I/O. For example:

template< class T> complex<T> operator+(const complex<T>&,const complex<T>&);
template< class T> complex<T> operator+(const complex<T>&,const T&;
template< class T> complex<T> operator+(const T&,const complex<T>&);
//similarly: -,*,/,==,and,!=
template< class T> complex<T> operator+(const complex<T>&);
template< class T> complex<T> operator-(const complex<T>&);
template< class T> T real(const complex<T>&);
template< class T> T imag(const complex<T>&);
template< class T> complex<T> conj(const complex<T>&);
template< class T> complex<T> sin(const complex<T>&);
//similarly:sinh,sqrt,tan,tanh,con,cosh,exp,log,and log10
template< class T> complex<T> pow(const complex<T>&,int);
template< class T> complex<T> pow(const complex<T>&,const T&);
template< class T> complex<T> pow(const complex<T>&,const complex<T>&);

If you don´t know how to work with templates, I recommend you the following book:

97 Addison Wesley - The C + + Programming Language - Stroustrup (Third Edition)

and I have used the class here:

http://www.codeproject.com/Articles/199800/Evaluate-complex-and-real-math-calculator