title: Trouble getting required output in C++
body: <p>We received a question in an assignment. I had trouble interpreting it so I rewrote it in c++, with the same conditions. However, I cannot seem to get the correct outputs listed in the question. Can anybody advise me on how to proceed?</p>
  <p>This is a snip of the Question.
  <img src="https://i.stack.imgur.com/9L2t8.png" alt="1" /></p>
  <p>Here is my code:</p>
  <pre class="lang-cpp prettyprint-override"><code>    #include &lt;iostream&gt;
      #include &lt;string&gt;
      using namespace std;
      int main(){
          int n; //AreWeThereYet
          string a;
          a=&quot;Yes we have arrived&quot;;
          string b;
          b=&quot;We just left&quot;;
          string c;
          c=&quot;That was annoying&quot;;
          string d;
          d=&quot;Almost&quot;;
          int i;
      
          cout &lt;&lt; &quot;enter n&quot; &lt;&lt; endl;
          cin &gt;&gt; n;
      
          for(int i=0;i&lt;=n;i++){
              //here starts the calc
              if(n==0){
                  cout &lt;&lt; a &lt;&lt; endl;
                  return 0;
              }
              if(n&gt;5){
                  cout &lt;&lt; b &lt;&lt; endl;
                  n=(n-1);
              }else if(n&gt;1){
                  n=(n-2);
                  cout &lt;&lt; c &lt;&lt; endl;
              }else{
                  cout &lt;&lt; d &lt;&lt; endl;
                  n=(n-1);
              }
          }
      }
  </code></pre>
  <p>The loop seems to be unable to output the first and last question.</p>
  <p>I figured that if I replicate the question, I could go by trial and error to attain the answers I needed.
  Below I've attached an image of my output. I expected the entry of '1' to output &quot;Almost&quot; followed by &quot;Yes we have arrived&quot;.</p>
  <p><a href="https://i.stack.imgur.com/Ws2Kz.png" rel="nofollow noreferrer">Current output</a></p>