The teacher has fed up with the students making noise in the class room, so in order to make them quite, she thinks of a task - "Asks them to count the number of vowels in the name". So teachers said any one student name, and students have to tell the number of vowels in the name.
So, help the teacher by writing a program using functions to find the number of vowels in the name.
Input Format: Input consists of a string.
Output Format: Output consists of an integer saying the number of vowel in the given word.
Refer sample Input and Output for further specifications.
#include <iostream>
#include <string>
int main()
{
std::cout << "Enter the name: ";
std::string name;
std::getline(std::cin, name);
int count = 0;
for(size_t i = 0; i < name.size(); ++i)
{
switch(toupper(name[i]))
{
case 'A': case 'E': case 'I': case 'O': case 'U' : count++; break;
}
}
std::cout << "The number of vowels in the name is: " << count << "\n";
return 0;
}
Comments
Leave a comment