title: Solve system of two equations with two unknowns
body: <p>Solve the system of two equations with two unknowns below:</p>
  
  <p><img src="https://i.stack.imgur.com/bBZrl.png" alt="enter image description here"></p>
  
  <p>a1, b1, c1, a2, b2 and c2 are inputted by the user himself.</p>
  
  <p>I've been trying to find a math solution for the problem first and I can't seem to go far..</p>
  
  <p>What I've tried so far is :</p>
  
  <ol>
  <li>From first equation to find y. (b1y = c1-a1x, y = (c1-a1x)/b1)</li>
  <li>Then I replace y in the second equation and I get one equation with 1 unknown in this case x. However, I can't solve the equation, I get some odd numbers / equations and stopped here.</li>
  </ol>
  
  <p>Is this correct or is there an easier way to do this?</p>
  
  <p>Current code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  int main()
  {
      int a1, b1, c1, a2, b2, c2;
      cout &lt;&lt; "Enter the values for the first equation." &lt;&lt; endl;
      cout &lt;&lt; "Enter the value for a1" &lt;&lt; endl;
      cin &gt;&gt; a1;
      cout &lt;&lt; "Enter the value for b1" &lt;&lt; endl;
      cin &gt;&gt; b1;
      cout &lt;&lt; "Enter the value for c1" &lt;&lt; endl;
      cin &gt;&gt; c1;
      cout &lt;&lt; "Enter the values for the second equation." &lt;&lt; endl;
      cout &lt;&lt; "Enter the value for a2" &lt;&lt; endl;
      cin &gt;&gt; a2;
      cout &lt;&lt; "Enter the value for b2" &lt;&lt; endl;
      cin &gt;&gt; b2;
      cout &lt;&lt; "Enter the value for c2" &lt;&lt; endl;
      cin &gt;&gt; c2;
      cout &lt;&lt; "Your system of equations is the following:" &lt;&lt; endl;
      cout &lt;&lt; a1 &lt;&lt; "x+" &lt;&lt; b1 &lt;&lt; "y=" &lt;&lt; c1 &lt;&lt; endl;
      cout &lt;&lt; a2 &lt;&lt; "x+" &lt;&lt; b2 &lt;&lt; "y=" &lt;&lt; c2 &lt;&lt; endl;
  
  if ((a1 * b2) - (b1 * a2) == 0){
      cout &lt;&lt; "The system has no solution." &lt;&lt; endl;
  }
  else{
      res_x = ((c1*b2) - (b1*c2))/((a1*b2)-(b1*a2));
      res_y = ((a1*c2) - (c1*a2)) / ((a1*b2) - (b1*a2));
      cout &lt;&lt; "x=" &lt;&lt; res_x &lt;&lt; " y=" &lt;&lt; res_y &lt;&lt; endl;
  }
  
      return 0;
  }
  </code></pre>