The imag() function is defined in the complex header file. The imag() function is used to find the imaginary part of the complex number.
template<class T> T imag(const complex<T>& z);
Parameter: This method takes a mandatory parameter z: which represents the given complex number.
Return: It returns the imaginary part of the complex number.
Below programs illustrate the above function:-
Complex Number = (20.3,4.9) Imag part of the complex number is =4.9
Complex Number = (2,2) Imag part of the complex number is =2
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Function Overloading vs Function Overriding in C++
- How to call some function before main() function in C++?
- How to call function within function in C or C++
- Difference between user defined function and library function in C/C++
- Function overloading and return type
- Function Pointer in C
- Function overloading and const keyword
- Function Overloading and float in C++
- Extra brackets with function names in C/C++
- Function Interposition in C with an example of user defined malloc()
- A C/C++ Function Call Puzzle
- std::tuple, std::pair | Returning multiple values from a function using Tuple and Pair in C++
- Function Overloading in C++
- strtoul() function in C/C++
- wcscspn() function in C/C++
- asctime() function in C++
- atanh() function in C++ STL
- vector rbegin() and rend() function in C++ STL
- wcschr() function in C++
- unordered_multimap begin() and end() function in C++ STL
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.