title: How to Print Out the Square Root of A Negative Number with i Displayed in C
body: <p>I am trying to figure out how to display the square root of a number if it happens to be negative (as it is entered by the user), and if so, display it correctly with the "i" displayed as well. When I do the normal <code>sqrt</code> function, the result is always something like -1.#IND. When I tried using the double complex variables, the positive numbers nor the negative numbers would come out clean. </p>
  
  <p>Below is my code; the comments are what my goal is. The 4 num variables are entered by the user and can be any integer, positive or negative. </p>
  
  <pre><code> //  Display the square root of each number.  Remember that the user can enter negative numbers and 
  //  will need to find the negative root with the "i" displayed.
  printf("\nThe square root of %d is %.4f", num1, sqrt(num1));
  printf("\nThe square root of %d is %.4f", num2, sqrt(num2));
  printf("\nThe square root of %d is %.4f", num3, sqrt(num3));
  printf("\nThe square root of %d is %.4f", num4, sqrt(num4));
  </code></pre>