C++ vowel count
Posted by Samath
Last Updated: January 07, 2021

Develop a C++ console application that uses a loop and an array to accept five words from a user and consequently with the aid of a selection structure count the number of vowels that constitutes each of the accepted words. Ultimately the console application should display the number of vowels that constitutes each of the accepted words.

#include <iostream>
#include <string>
using namespace std;
int main(int argc, char *argv[])
{
	string word[5];
	int count[5] = {0};
	
	
	for(int i=0;i<5;i++)
	{		
		cout<<"Enter a word: ";
		cin>>word[i];
	}
	
	cout<<"\n";
	cout<<"\n";
	
	for(int i=0;i<5;i++)
	{		
		char * mywordconversion = new char[word[i].size() + 1];
		std::copy(word[i].begin(), word[i].end(), mywordconversion);
		mywordconversion[word[i].size()] = '\0'; 
		
		for(int j=0;j<word[i].size();j++)
		{
if(mywordconversion[j]=='a'||mywordconversion[j]=='e'||
mywordconversion[j]=='i'||mywordconversion[j]=='o'||mywordconversion[j]=='u')
			{
				count[i]++;
			}
		}
		
		cout<<word[i]<<": "<<count[i]<<" vowel";
		cout<<"\n";
		cout<<"\n";
		delete[] mywordconversion;
	}
	
 
	return 0;
}