fork download
  1. #include <stdio.h>
  2. #include <complex.h>
  3.  
  4. int main(void)
  5. {
  6. double complex z = cpow(-1.0, 2./3.);
  7. printf("z = (-1+0i)^(2/3) = %.5f%+.5fi\n", creal(z), cimag(z));
  8. printf("z*z = %.5f+%.5fi\n", creal(z*z), cimag(z*z));
  9. printf("z*z*z = %.5f+%.5fi\n", creal(z*z*z), cimag(z*z*z));
  10. }
Success #stdin #stdout 0s 4540KB
stdin
Standard input is empty
stdout
z = (-1+0i)^(2/3) = -0.50000+0.86603i
z*z = -0.50000+-0.86603i
z*z*z =  1.00000+-0.00000i