Write a Cprogram that prompts the user to input a sentence A
Write a C++program that prompts the user to input a sentence. After the sentence is input the program will compute the number of vowels in the sentence. A vowel is one of the letters a, e, i, o, and u. If a vowel is capitalized the program should count that as a vowel as well. Sample output will look like this: Please enter a sentence: A sentence with words might 100k like this There are 12 vowels
Solution
#include <iostream>
using namespace std;
int main() {
// your code goes here
char str[100];
cout << \"Please enter a sentence : \";
cin.getline(str,sizeof(str));
int count = 0;
int i=0;
while(str[i])
{
if(str[i]==\'A\' || str[i] == \'a\' || str[i]==\'e\' || str[i] == \'E\' || str[i]==\'I\' || str[i] == \'i\' || str[i]==\'O\' || str[i] == \'o\' || str[i]==\'U\' || str[i] == \'u\')
count++;
i++;
}
cout << \"There are \" << count << \" vowels.\";
return 0;
}
