Answer to Question #315065 in C++ for Secret Agent

Question #315065

Vowels Survival

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
1
Expert's answer
2022-03-22T16:13:23-0400
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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog