imag - C complex.h

C examples for complex.h:imag

type

function template

From


<complex>
<complex.h>

Prototype

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

double imag (ArithmeticType x);  // additional overloads

Description

Imaginary part of complex

Parameters

Parameter Description
x Complex value.

Return value

Imaginary part of x.

Example

Demo Code


#include <iostream> // std::cout
#include <complex> // std::complex, std::imag

int main ()// w  w w .j  a v  a  2 s  .c o m
{
  std::complex<double> mycomplex (20.0,2.0);

  std::cout << "Imaginary part: " << std::imag(mycomplex) << '\n';

  return 0;
}

Related Tutorials