I have to write a program that does the following:
Write a program that reads a string and outputs the number of times each lowercase vowel appears in it. Your program mist contain a function which one of its parameters as a string variable and return the number of times each lowercase vowel appears in it. Also write a program to test your function. (Note that if str is a variable of type string, then str.at(i) returns the character at the ith position. The position of the first character is 0. Also, str.length() returns the length of the str, that is, the number of characters in str.
This is what I have so far. Please help
#include <string>
#include <iostream>
using namespace std;
int Vowels (string vowel, int number_a, int number_e, int number_i, int number_o, int number_u);
int main ()
{
string vowel = "King University used to be called King College";
static char number_a = 'a';
static char number_e = 'e';
static char number_i = 'i';
static char number_o = 'o';
static char number_u = 'u';
cout << vowel;
cin >> vowel;
getline(cin, vowel);
cout << "The number of each lower case vowel in this sentece is as follows: ";
cout << endl;
cout << "a = " << number_a;
cout << "e = " << number_e;
cout << "i = " << number_i;
cout << "o = " << number_o;
cout << "u = " << number_u;
}
{
for (i = 0; i < str.length(); i++)
if (str.at(i)==number_a) number_a++;
return i;
}
Dont do what you did above, only give the function 1 parameter which is the string and then go through that string and test if it is a lowercase vowel.