title: C++ if...then statement
body: <p>So I'm trying to make a simple application that quizzes the user. It asks a question and the user answers 1, 2, 3, or 4. The app then takes that answer and if it is correct adds +1 to the total_score which will be displayed at the end. Everything looks sound to me, but when I run it and I get to the <code>if (q1_valid == false)</code> part it skips the cout and runs the goto no matter if q1_valid is true or false.</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  int main()
  {
      int q1_answer;
      int total_score;
      bool q1_correct;
      bool q1_valid;
  
      Question_1:
      cout &lt;&lt; "Question 1 (#3 is correct)" &lt;&lt; endl;
      cout &lt;&lt; "1.) Answer 1" &lt;&lt;endl;
      cout &lt;&lt; "2.) Answer 2" &lt;&lt;endl;
      cout &lt;&lt; "3.) Answer 3" &lt;&lt;endl;
      cout &lt;&lt; "4.) Answer 4" &lt;&lt;endl;
      cin &gt;&gt; q1_answer;
  
      if (q1_answer == 1)
      q1_correct = false;
      q1_valid = true;
  
      if (q1_answer == 2)
      q1_correct = false;
      q1_valid = true;
  
      if (q1_answer == 3)
      q1_correct = true;
      q1_valid = true;
  
      if (q1_answer == 4)
      q1_correct = false;
      q1_valid = true;
  
      if (q1_valid == false)
      cout &lt;&lt; "Invalid answer." &lt;&lt;endl;
      goto Question_1;
  
      if (q1_correct == true)
      cout &lt;&lt; "Correct!" &lt;&lt;endl;
      (total_score + 1);
      goto Question_2;
  
      if (q1_correct == false)
      cout &lt;&lt; "Incorrect." &lt;&lt;endl;
      goto Question_2;
  
      if (q1_valid == false)
      goto Question_1;
  
      Question_2:
      cout&lt;&lt; "Q2" &lt;&lt;endl;
  cin.ignore();
  cin.ignore();
  }
  </code></pre>