MCQs
imag part will return the imaginery part of the complex number.
Output:
$ g++ comp5.cpp
$ a.out
2
None.
In this program, we are adding both complex number and finding the square root of it.
Output:
$ g++ comp4.cpp
$ a.out
(6.12132,3.70711)
We are adding the two complex numbers and printing the result.
Output:
$ g++ comp3.cpp
$ a.out
c1: (4,3)(7.65844,6.40819)
We are multiplying the complex number by 2.
Output:
$ g++ comp2.cpp
$ a.out
(4,6)
We are just copying the value of c_int into c_double, So it’s printing as (4,5).
Output:
$ g++ comp1.cpp
$ a.out
(4,5)
There are three real types in complex numbers. They are float complex, double complex, long
double complex.
In this program, we are finding the square of the complex number.
Output:
$ g++ comp.cpp
$ a.out
(-240,128)
None.
We can declare the complex number by using complex(3,4) where 3 is a real number and
4 is imaginary part.