title: Program output (Basic operators for c++). Order of operations?
body: <pre><code>// H2.cpp : Tihs program runs different mathmatical operations on numbers given by the user
  
  #include &lt;iostream&gt;
  #include &lt;iomanip&gt;
  using namespace std;
  
  int main()
  {
      int a;
      cout &lt;&lt; "Enter a number for a: "; //Prompts the user for a and b inputs
      cin &gt;&gt; a;
  
      int b;
      cout &lt;&lt; "Enter a number for b: ";
      cin &gt;&gt; b;
  
      cout &lt;&lt; "A is " &lt;&lt; a &lt;&lt; "\tB is " &lt;&lt; b &lt;&lt; endl;
      cout &lt;&lt;"Sum of a and b is equal to " &lt;&lt; a &lt;&lt; " + " &lt;&lt; b &lt;&lt; " and the result is " &lt;&lt; (a + b) &lt;&lt; endl; //Performs addition operator and gives output
      cout &lt;&lt;"Product of a and b is equal to " &lt;&lt; a &lt;&lt; " * " &lt;&lt; b &lt;&lt; " and the result is " &lt;&lt; (a * b) &lt;&lt; endl;
      cout &lt;&lt;"a &gt; b is " &lt;&lt; a &lt;&lt; " &gt; " &lt;&lt; b &lt;&lt; " and the result is " &lt;&lt; (a &gt; b) &lt;&lt; endl;
      cout &lt;&lt;"a &lt; b is " &lt;&lt; a &lt;&lt; " &gt; " &lt;&lt; b &lt;&lt; " and the result is " &lt;&lt; (a &lt; b) &lt;&lt; endl;
      cout &lt;&lt;"a == b is " &lt;&lt; a &lt;&lt; " == " &lt;&lt; b &lt;&lt; " and the result is " &lt;&lt; (a == b) &lt;&lt; endl; //Performs boolean operator and outputs result
      cout &lt;&lt;"a &gt;= b is " &lt;&lt; a &lt;&lt; " &gt;= " &lt;&lt; b &lt;&lt; " and the result is " &lt;&lt; (a &gt;= b) &lt;&lt; endl;
      cout &lt;&lt;"a &lt;= b is " &lt;&lt; a &lt;&lt; " &lt;= " &lt;&lt; b &lt;&lt; " and the result is " &lt;&lt; (a &lt;= b) &lt;&lt; endl;
      cout &lt;&lt;"a != b is " &lt;&lt; a &lt;&lt; " != " &lt;&lt; b &lt;&lt; " and the result is " &lt;&lt; (a != b) &lt;&lt; endl;
      cout &lt;&lt;"a -= b is " &lt;&lt; a &lt;&lt; " -= " &lt;&lt; b &lt;&lt; " and the result is a = " &lt;&lt; (a -= b) &lt;&lt; endl; //Performs - operator on a - b and makes a equal to the new result
      cout &lt;&lt;"a /= b is " &lt;&lt; a &lt;&lt; " /= " &lt;&lt; b &lt;&lt; " and the result is a = " &lt;&lt; (a /= b) &lt;&lt; endl;
      cout &lt;&lt;"a %= b is " &lt;&lt; a &lt;&lt; " %= " &lt;&lt; b &lt;&lt; " and the result is a = " &lt;&lt; (a %= b) &lt;&lt; endl; //Performs % operator on a % b and makes a equal to the new result. Ripple effect created from previous 2 lines as the value of a changes each time.
  
  return 0;
  </code></pre>
  
  <p>The output I'm concerned with is here:</p>
  
  <pre><code>a -= b is -4198672 -= 4198672 and the result is a = -4198672
  a /= b is -1 /= 4198672 and the result is a = -1
  a %= b is -1 %= 4198672 and the result is a = -1
  </code></pre>
  
  <p>It seems like the value for a being displayed is the value of a after the line of code is executed. I'm sure that has something to do with the order of operations, but I'm not sure how to get around that. Any help is greatly appreciated.</p>