title: C program to find out both real and complex roots for quadratic equation (ax^2 + bx + c = 0)
body: <p>This is the code I tried to get real and complex value for this equation, ax^2 + bx + c = 0.</p>
  <pre><code>#include &lt;math.h&gt;
  #include &lt;stdio.h&gt;
  
  int main() {
      double a, b, c, d, x1, x2, i = sqrt(-1);
      scanf(&quot;%lf %lf %lf&quot;, &amp;a, &amp;b, &amp;c);
      d = (b * b) - (4 * a * c);
      x1 = (-b + sqrt(d)) / (a + a);
      x2 = (-b - sqrt(d)) / (a + a);
      if (d &lt; 0) {
          printf(&quot;Complex solution\n&quot;);
          printf(&quot;R1 = %.2lf\n&quot;, x1);
          printf(&quot;R2 = %.2lf\n&quot;, x2);
      } else
      if (a == 0)
          printf(&quot;Value of a must be non zero\n&quot;);
      else {
          printf(&quot;R1 = %.2lf\n&quot;, x1);
          printf(&quot;R2 = %.2lf\n&quot;, x2);
      }
      return 0;
  }
  </code></pre>
  <p>And I want to get an answer with <code>i</code> (eg: <code>-.4 + 4i</code>).</p>