In: Computer Science
The algorithm ( pseudo code ) for the problem is given below:
start
count=0 // initialize total vowel count as 0
ac=0,ec=0,ic=0,oc=0,uc=0 // initialize count for a e i o u respectively
while (True)
{
ch = input () // takes the input from user
if (ch== "$")
break // if input is $ then exit loop
else if(ch == "a") // this section check for "a"
count=count+1 // total count is incremented if the character entered is "a"
ac=ac+1 // count of "a" is incremented
else if(ch == "e") // this section check for "e"
count=count+1 // total count is incremented if the character entered is "e"
ec=ec+1 // count of "e" is incremented
else if(ch == "i") // this section check for "i"
count=count+1 // total count is incremented if the character entered is "i"
ic=ic+1 // count of "i" is incremented
else if(ch == "o") // this section check for "o"
count=count+1 // total count is incremented if the character entered is "o"
oc=oc+1 // count of "o" is incremented
else if(ch == "u") // this section check for "u"
count=count+1 // total count is incremented if the character entered is "u"
uc=uc+1 // count of "u" is incremented
}
print ( "Total number of vowels :" , count) // print total count
print("#A :" , ac ,"\n #E : ", ec,"\n # I : ", ic,"\n #O : ", oc,"\n #U : ", uc) // prints the individual count of each vowel