title: Printing input string words in reverse order
body: <p>Using <code>if</code> <strong><em>and</em></strong> <code>while</code>/<code>do</code>-<code>while</code>, my job is to print following user's inputs (string value) in reverse order.</p>
  
  <p>For example:</p>
  
  <p>input string value : "You are American"
  output in reverse order : "American are You"</p>
  
  <p>Is there any way to do this?</p>
  
  <p>I have tried</p>
  
  <pre><code>string a;
  cout &lt;&lt; "enter a string: ";
  getline(cin, a);
  a = string ( a.rbegin(), a.rend() );
  cout &lt;&lt; a &lt;&lt; endl;
  return 0;
  </code></pre>
  
  <p>...but this would reverse the order of the words <strong>and</strong> spelling while spelling is not what I'm going for. </p>
  
  <p>I also should be adding in <code>if</code> and <code>while</code> statements but do not have a clue how.</p>