abs - C complex.h

C examples for complex.h:abs

Type

function template

From


<complex>
<complex.h>

Description

Absolute value of complex

Prototype

template<class T>
T abs (const complex<T>& x);

Parameters

Parameter Description
x Complex value.

Return value

The absolute value of x.

Demo Code


#include <iostream>
#include <complex>

int main ()//from  w  w w .  j  av  a 2s  .  com
{
  std::complex<double> mycomplex (3.0,4.0);

  std::cout << "The absolute value of " << mycomplex << " is " << std::abs(mycomplex) << '\n';

  return 0;
}

Related Tutorials