title: C++ basics - If statement testing
body: <p>it's my first day messing around with C++. I'm trying to do just a really basic code looking for the roots in a quadratic equation. Here is my code so far: </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cmath&gt;
  
  int main () {
  
      int a, b, c;
      double root1, root2;
  
      std::cout &lt;&lt; "Enter the integers a, b, and c to fit in the quadratic equation: ax^2 + bx + c &gt;&gt; " &lt;&lt; std::endl;
      std::cout &lt;&lt; "a = ";
      std::cin &gt;&gt; a;
      std::cout &lt;&lt; "b = ";
      std::cin &gt;&gt; b;
      std::cout &lt;&lt; "c = ";
      std::cin &gt;&gt; c;
      std::cout &lt;&lt;"\n";
      std::cout &lt;&lt; "Quadratic equation to solve is : " &lt;&lt; a &lt;&lt; "x^2 + " &lt;&lt; b &lt;&lt; "x + " &lt;&lt; c &lt;&lt;std::endl;
  
      root1 = (-b + sqrt(b*b - 4*a*c))/(2*a); 
      root2 = (-b - sqrt(b*b - 4*a*c))/(2*a);
  
      if (root1 &amp;&amp; root2 != nan) {
          std::cout &lt;&lt; "root 1 = " &lt;&lt; root1 &lt;&lt; std::endl;
          std::cout &lt;&lt; "root 2 = " &lt;&lt; root2 &lt;&lt; std::endl;
      }
      else 
      std::cout &lt;&lt; "no root exists" &lt;&lt; std::endl;
  
      return 0;
      }
  </code></pre>
  
  <p>I'm getting this error:</p>
  
  <pre><code>invalid operands to binary expression ('double' and 'double (*)(const char *)')
  </code></pre>
  
  <p>in the line:</p>
  
  <pre><code>if (root1 &amp;&amp; root2 != nan) 
  </code></pre>
  
  <p>I'm looking for a simple test to see if the roots exist and this obviously doesn't work. Thanks in advance for your help!</p>