How to use csqrt() to compute the complex square root of complex n in C

1 Answer

0 votes
#include <stdio.h>
#include <complex.h>
 
int main(void)
{
    double complex x = csqrt(-4);
    printf("Square root of -4 is %.1f%+.1fi\n", creal(x), cimag(x));
    
    double complex y = csqrt(9);
    printf("Square root of 9 is %.1f%+.1fi\n", creal(y), cimag(y));
 
    return 0;
}
  
/*
run:
 
Square root of -4 is 0.0+2.0i
Square root of 9 is 3.0+0.0i

*/

 



answered Aug 27, 2016 by avibootz

Related questions

1 answer 194 views
1 answer 200 views
1 answer 203 views
1 answer 177 views
1 answer 171 views
1 answer 183 views
183 views asked May 7, 2019 by avibootz
...