 Open in App
Not now

# sin() function for complex number in C++ with Examples

• Last Updated : 17 Aug, 2022

The sin() function for complex numbers is defined in the complex header file. This function is the complex version of the sin() function. This function is used to calculate the complex sine of complex number z. This function returns the sine of complex number z.

Syntax:

`sin (z);`

Parameter:

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

Return value: This function returns the sin() of complex number z. Below programs illustrate the sin() function in C++: Program 1:-

## CPP

 `// C++ program to demonstrate``// example of sin() function``// for Complex numbers`` ` `#include ``#include ``using` `namespace` `std;`` ` `int` `main ()``{``  ``complex<``double``> complexnumber (0.0, 1.0);`` ` ` ` `  ``// use of sin() function for complex number``  ``cout << "The ``sin` `of " << complexnumber << " is "``                     ``<< ``sin``(complexnumber) <

Output:

`The sin of (0,1) is (0,1.1752)`

Time Complexity: O(1)
Auxiliary Space: O(1)

Program 2:-

## CPP

 `// C++ program to demonstrate``// example of sin() function``// for Complex numbers` `#include& lt; iostream & gt;``#include& lt; complex & gt;``using` `namespace` `std;` `int` `main()``{``    ``complex& lt;``    ``double``& gt;``    ``complexnumber(1.0, 0.0);` `    ``// use of sin() function for complex number``    ``cout& lt;``    ``<``    ``"``    ``The ``sin` `of& quot;``    ``<``    ``<``    ``complexnumber& lt;``    ``<``    ``"``    ``is& quot;``    ``<``    ``<``    ``sin``(complexnumber) & lt;``    ``<``    ``endl;` `    ``return` `0;``}`

Output:

`The sin of (1,0) is (0.841471,0)`

Time Complexity: O(1)
Auxiliary Space: O(1)

My Personal Notes arrow_drop_up