arg() function for Complex Number in C++

A complex number is a number that is expressed in the form of a + bi, where a and b are real numbers. i is the imaginary part of number.

The argument is the angle between the positive axis and the vector of the complex number. For a complex number

z = x + iy denoted by arg(z),

For finding the argument of a complex number there is a function named arg() of a complex number in the complex header file.




The function accepts a complex number as input to calculate the value of the argument for that complex number.

Returned value

The function returns the argument of the complex number.


 Live Demo

using namespace std;
int main (){
   double a = 12.0, b = 56.0;
   complex<double> complexnumber (a, b);
   cout<<"The argument of complex number "<<a<<" + i"<<b<< " is: ";
   return 0;


The argument of complex number 12 + i56 is: 1.3597