Related Articles
conj() function in C++ with Examples
• Last Updated : 10 Oct, 2018

The conj() function is defined in the complex header file. This function is used to find the conjugate of the complex number z. If we represent a complex number z as (real, img), then its conjugate is (real, -img).

Syntax:

```template<class T> complex<T>
conj (const complex<T>& Z);
```

Parameter:

• z: This method takes a mandaory parameter z which represents the complex number.

Return value: This function returns the conjugate of the complex number z.

Below programs illustrate the conj() function for complex number in C++:

Example 1:-

 `// C++ program to demonstrate``// example of conj() function.``  ` `#include ``using` `namespace` `std;``  ` `// driver program``int` `main ()``{``  ``complex<``double``> complexnumber (3.0, 2.4);``  ` `  ``cout << ``"The conjugate of "` `<< complexnumber << ``" is: "``;``  ` `  ``// use of conj() function``  ``cout << conj(complexnumber) << endl;``  ``return` `0;``}`
Output:
```The conjugate of (3,2.4) is: (3,-2.4)
```

Example 2:-

 `// C++ program to demonstrate``// example of conj() function.``  ` `#include ``using` `namespace` `std;``  ` `// driver program``int` `main ()``{``  ``complex<``double``> complexnumber (2.0, 9.0);``  ` `  ``cout << ``"The conjugate of "` `<< complexnumber << ``" is: "``;``  ` `  ``// use of conj() function``  ``cout << conj(complexnumber) << endl;``  ``return` `0;``}`
Output:
```The conjugate of (2,9) is: (2,-9)
```
Want to learn from the best curated videos and practice problems, check out the C++ Foundation Course for Basic to Advanced C++ and C++ STL Course for foundation plus STL.  To complete your preparation from learning a language to DS Algo and many more,  please refer Complete Interview Preparation Course.
My Personal Notes arrow_drop_up