| #include <iostream> #include <complex>
 using namespace std;
 
 int main(int argc, char *argv[])
 {
 complex<double> a(1, 2), b(3, 4);
 
 cout << "a = " << a << ", b = " << b << endl;
 cout << "a + b = " << a + b << endl;
 cout << "a * b = " << a * b << endl;
 
 cout << "\nthe real part of a is " << real(a) << endl;
 cout << "the imaginary part of b is " << imag(b) << endl;
 cout << "the magnitude of a is " << abs(a) << endl;
 
 cout << "\ne^a = " << exp(a) << endl;
 cout << "ln(b) = " << log(b) << endl;
 
 return 0;
 }
 
 |