Table of Contents

cimag

double cimag(double complex z);

description of cimag

calculate the complex imaginary part

#include <stdio.h>
#include <complex.h>
 
int main( void )
{
 
   long double complex zlong=4.2 + I*2.34;
   double complex zdouble=(double complex)zlong;
 
   double result;
 
   result = cimag(zdouble);
   printf("cimag(%f + I*%f) = %f\n", creal(zdouble), cimag(zdouble), result);
   return 0;
}

output of cimag c example

  cimag(4.200000 + I*2.340000) = 2.340000