The C++ <complex> ‘abs’ function compute the absolute value of the complex number.The declaration of the ‘abs’ function is shown below.
|template<class T> T abs(const complex<T>& x);|
x -The complex number whose magnitude is to be computed.
T -The absolute value of ‘x’.
Some points to note:
i)The ‘abs’ compute the square root of the sum of the square of the real part and imaginary part,
The magnitude of a complex number is also known as modulus of the complex number.
cout<< abs( c1 ) << endl ;
<< abs( c2 );