creat a c++ program that has 3 functions
main will ask user to input a string
isvowel will loop the string and return true if there is a vowel
printvowle will print all the vowels found
#include <iostream> #include <string> using namespace std; bool isvowel(char ch) { return ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' || ch == 'A' || ch == 'E' || ch == 'I' || ch == 'O' || ch == 'U'; } void printvowle(string s) { cout << "Vowels are: "; for (int i = 0; i < s.length(); i++) { if (isvowel(s[i])) cout << s[i] << " "; } cout << endl; } int main() { string s; cout << "Enter a string: "; getline(cin, s); printvowle(s); return 0; }
Get Answers For Free
Most questions answered within 1 hours.