title: How to make a C++ program that factors a quadratic expression into the form (x + a)(x + b)
body: <p>I have the code for a program (in C++) that intends to completely factor a quadratic equation completely, but it isn't really working. </p>
  
  <p>My approach is to use a method called <strong>decomposition</strong>, which states that in the equation </p>
  
  <blockquote>
    <p>x² + bx + c</p>
  </blockquote>
  
  <p>where <em>x</em> is a variable and <em>b</em> and <em>c</em> are integers, this equation is equal to </p>
  
  <blockquote>
    <p>(x + <em>d</em>)(x + <em>e</em>)</p>
  </blockquote>
  
  <p>where <em>d</em> and <em>e</em> are numbers that add to <em>b</em> and multiply to <em>c</em>. </p>
  
  <p>Currently, this is my code: </p>
  
  <pre><code>#include &lt;iostream&gt;
  int main()
  {
      int a, b, c;
      std::cout &lt;&lt; "Enter the parts of an equation and we will factorise it for you" &lt;&lt; std::endl;
      std::cout &lt;&lt; "        2" &lt;&lt; std::endl;
      std::cout &lt;&lt; "Enter x  :" &lt;&lt; std::endl;
      std::cin &gt;&gt; a;
      std::cout &lt;&lt; "Enter x" &lt;&lt; std::endl;
      std::cin &gt;&gt; b;
      std::cout &lt;&lt; "Enter the other number" &lt;&lt; std::endl;
      std::cin &gt;&gt; c;
  
      int d = rand() % RAND_MAX + 1;
      int e = rand() % RAND_MAX + 1; 
      if (a = 1) {
          if (d + e == b, d * e == c) {
              std::cout &lt;&lt; "The factorised form of your equation is:" &lt;&lt; std::endl;
              std::cout &lt;&lt; "(x + " &lt;&lt; d &lt;&lt; ")(x + " &lt;&lt; e &lt;&lt; std::endl;
          }
  
      return 0;
  }
  </code></pre>
  
  <p>I'm trying to look for another way of finding the values of d and e, since generating two random integer and checking for their sums and products doesn't seem to be working. </p>