Home » C++ Programming » Numbers » Question
  1. What is the output of this program?
    #include <iostream>
    #include <complex>
    using namespace std;
    int main()
    {
    complex<double> CompNum1(2.0,4.0);
    cout << "Complex Number: " << CompNum1;
    complex<float> CompNum2(polar(3.0,0.25));
    cout << CompNum1 + complex<double>(CompNum2.real(),CompNum2.imag());
    return 0;
    }
    1. Complex Number: (4.90674,4.74221)(2,4)
    2. Compilation Error
    3. Runtime Error
    4. Complex Number: (2,4)(4.90674,4.74221)
    5. None of these
Correct Option: D

We are adding the two complex numbers and printing the result.



Your comments will be displayed only after manual approval.