#include <iostream>
using namespace std;

bool isVowel(char character);

int main()
{
char character;

cout << "Enter a letter, if it is a vowel this program will tell you" << endl;

{
cin >> character;
cout << isVowel(character) << endl;

if(isVowel(character)==true)
}

bool isVowel(char ch)
{	
		if('A'==ch||'a'==ch||'E'==ch||'e'==ch||'I'==ch||'i'==ch||'O'==ch||'o'==ch||'U'==ch||'u'==ch)
	
	return true;
}
else return false;
}

Recommended Answers

All 2 Replies

RTFCM

(Read the Full Compiler Messages)

Pay attention to matching opening and closing { }

Good start but there are numerous problems with your code. I added comments and highlighted them in red for you to see where you went wrong.
Also, one thing i would suggest is review how to properly format code. it is very hard to understand what your code is doing just from it not being formatted.

using namespace std;

// This is minor but you do not need a parameter when you declare functions.
// You just need the type i.e. isVowel(char) rather than isVowel(char character)
bool isVowel(char character);

int main()
{
char character;

cout << "Enter a letter, if it is a vowel this program will tell you" << endl;

// This bracket, along with its matching closing bracket, is not needed.
// I'm confused on why you added these in here.  Just remove them.
{
cin >> character;  // Good character input

// Your isVowel function returns a bool, not a string to print.  What are you trying 
// to display to the user?
cout << isVowel(character) << endl;

// When you evaluate bool functions in an if statement you do not need to do
// '== true', just do if(isVowel(character)) { <actions to perform> };
if(isVowel(character)==true)
}

// This function is correct but function definitions go before or after main, not in 
// the middle.
bool isVowel(char ch)
{	
		if('A'==ch||'a'==ch||'E'==ch||'e'==ch||'I'==ch||'i'==ch||'O'==ch||'o'==ch||'U'==ch||'u'==ch)
	
	return true;
}
else return false;
}

Also, i dont know what you are trying to output if the character is true. I would assume something like this.

if(isVowel(character))
		cout << "Letter is a vowel" << endl;
	else
		cout << "Letter is not a vowel" << endl;

One last thing, you are trying to return true and false from main. This is not allowed. main() returns int so usually you return 0 for a good termination and -1 for a bad termination.

Hope that helps.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.