answer exercise2 and show full stepSolutionPlease follow the


answer exercise#2 and show full step

Solution

Please follow the code and comments for description :

CODE :

#include <iostream> // required header files

using namespace std;

void vowelCount(string sentence); // function declaration

void vowelCount(string sentence) { // function initialisation

   int vowels = 0; // local varaibles
  
   for(int i = 0; i < sentence.length(); ++i) // iterate over the length of the line
   {
       if(sentence[i]==\'a\' || sentence[i]==\'e\' || sentence[i]==\'i\' || sentence[i]==\'o\' || sentence[i]==\'u\' || sentence[i]==\'A\' || sentence[i]==\'E\' || sentence[i]==\'I\' || sentence[i]==\'O\' || sentence[i]==\'U\') // check for hte vowels
       {
           ++vowels; // increment the count
       }
   }

   cout << \"The count of Vowels in the entered sentence are : \" << vowels << endl; // print the data to the console
}


int main() // driver method
{
   string sentence; // local varaible

   cout << \"Enter a sentence of string type : \"; // prompt for the user to enter the data
   getline(cin, sentence); // get the line from the user
   vowelCount(sentence); // call the function to count the vowels

   return 0;
}


OUTPUT :

Enter a sentence of string type : Earth is round in shape
The count of Vowels in the entered sentence are : 8


Hope this is helpful.

 answer exercise#2 and show full stepSolutionPlease follow the code and comments for description : CODE : #include <iostream> // required header files usi

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site