Complex Number Type

Q.

What is the output of this program?

1.
    #include 
2.
    #include 
3.
    using namespace std;
4.
    int main ()
5.
    {
6.
        complex mycomplex (20.0, 2.0);
7.
        cout << imag(mycomplex) << endl;
8.
        return 0;
9.
    }
A. 2
B. 20
C. 40
D. None of the mentioned

Answer : Option A

Explanation :

imag part will return the imaginery part of the complex number.
Output:
$ g++ comp5.cpp
$ a.out
2