imag(z) ফাংশন <complex> হেডারে সংজ্ঞায়িত। এটি কমপ্লেক্স নম্বরের ইমেজিনারি পার্ট রিটার্ন করে।
সিনট্যাক্স
template <class T> T imag(const complex<T>& z); উদাহরণ
#include <bits/stdc++.h>
using namespace std;
int main() {
complex<double> z1(2.2, 3.4);
complex<double> z2(32, 12);
cout << "z1 = " << z1 << ", imag = " << imag(z1) << endl;
cout << "z2 = " << z2 << ", imag = " << imag(z2) << endl;
}
আউটপুট
The complex number is: (2.2,3.4) The Imaginary part of the complex number is: 3.4 The complex number is: (32,12) The Imaginary part of the complex number is: 12