Answer to Question #291305 in C++ for ali

Question #291305

 Write a program that reads a character and then prints “It is a vowel”, if it is a vowel, “It is an operator”, if it is one of the five operators, and “It is something else”, if it is anything else.


1
Expert's answer
2022-01-27T10:47:22-0500
#include <iostream>
#include <string>
#include <math.h>


using namespace std;




bool isVowel(char character) { 
	string vowels = "AEIOUYaeiouy";
	for (int j = 0; j < vowels.size(); j++)
	{
		if (toupper(character) == toupper(vowels[j]))
		{
			return true;
		}
	}
	return false;
}
bool isOperator(char character) { 
	string operators = "^&|~.";
	for (int j = 0; j < operators.size(); j++)
	{
		if (toupper(character) == toupper(operators[j]))
		{
			return true;
		}
	}
	return false;
}


int main()
{
	char character;
	cout<<"Enter character: ";
	cin>>character;


	if(isVowel(character)){
		cout<<"It is a vowel\n\n";
	}else if(isOperator(character)){
		cout<<"It is an operator\n\n";
	}else{
		cout<<"It is something else\n\n";
	}








	system("pause");
	return 0;
}

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