by CodeChum Admin
Make me a program that accepts two random strings. Then, count the number of vowels that are in each of the strings and put it on separate variables.
Finally, for the survival of the vowels, subtract the total count of vowels of the first string to the vowels of the second string then print out its difference.
Easy, right? Then go and code as if your life depends on it!
Input
Two lines containing a string on each.
C++·is·fuN
CodeChum·is·AWEsome
Output
A line containing an integer.
6
int main()
{
string str;
string str2;
int count1;
int count2;
int result;
cin >> str;
cin >> str2;
for (int i = 0; i < str.size(); i++)
{
if (str[i] == 'a' || str[i] == 'e' || str[i] == 'i' || str[i] == 'o' || str[i] == 'u')
{
count1++;
}
}
for (int j = 0; j < str2.size(); j++)
{
if (str2[j] == 'a' || str2[j] == 'e' || str2[j] == 'i' || str2[j] == 'o' || str2[j] == 'u')
{
count2++;
}
}
result = count1 - count2;
cout << "A line containing an integer: " << endl;
cout << result << endl;
}
Comments
Leave a comment