title: Outputting vowels and consonants from strings in c++
body: <p>This is the question I have to answer:  </p>
  
  <pre>
  Write a program that declares two strings: s1 and s2.
  
  Initialize both of them using getline(cin, string) function.  
  
  a)      Output the length of each string  
  b)      Output the first appearance of a letter a in the first string  
  c)      Output the first appearance of a letter b in the second string  
  d)      Output the first word of each string  
  e)      Output the last word of each string  
  f)      Output first sentence reversed  
  g)      Output second sentence with the words reversed ( the last word goes first, second last second, and so on)  
  h)      Output the total number of vowels in the first sentence  
  i)      Output the total number of consonants in the second sentence  
  </pre>
  
  <p>This is what I have so far:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  
  using namespace std;     
  
  int main()  {
      string s1,s2,s3;
      int blank = 0;
      int counter1 = 0;
      int counter2 = 0;
      int counter3 = 0;
      int s2temp = 0;
  
      cout &lt;&lt; "enter two sentences" &lt;&lt;endl;
      getline (cin, s1);
      getline (cin, s2);
      s3=s2;
  
      // a
  
      cout &lt;&lt; "the length of the first string is " &lt;&lt; s1.length() &lt;&lt; endl;
      cout &lt;&lt; "the length of the second string is " &lt;&lt; s2.length() &lt;&lt; endl;
  
      // b
  
      cout&lt;&lt;"the first appearance of the letter 'A' in the first string is ";
      cout &lt;&lt; s1.find("a");
      cout &lt;&lt;endl;
  
      // c
  
      cout&lt;&lt;"the first appearance of the letter 'B' in the second string is ";
      cout &lt;&lt; s2.find("b");
      cout &lt;&lt;endl;
  
      // d
  
      int s1_first = s1.find(" ");
      int s2_first = s2.find(" ");
      cout &lt;&lt; "the first word in the first string is " &lt;&lt; s1.substr(0,s1_first) &lt;&lt;endl;
      cout &lt;&lt; "the first word in the second string is " &lt;&lt; s2.substr(0,s2_first) &lt;&lt;endl;
  
      // e
  
      cout &lt;&lt; "the last word in the first string is " &lt;&lt; s1.substr(s1.find_last_of(" "), s1.length()-1) &lt;&lt;endl;
      cout &lt;&lt; "the last word in the second string is " &lt;&lt; s2.substr(s2.find_last_of(" "), s2.length()-1) &lt;&lt;endl;
  
      // f
  
      for(int i = s1.length()-1; i &gt;= 0; i--)
          cout &lt;&lt;s1.substr (i,1)&lt;&lt;endl;
  
      // g
  
      return 0;
  }
  </code></pre>
  
  <p>I’ve tried a few different things for <code>g</code>, <code>h</code>, and <code>i</code>, but none have worked, so I thought I’d ask for help.</p>