switch case return only 1 value

Hi there ,

I'm doing revision that I left in the class due to insufficient time and I found that I stuck at the question again .

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <iostream>
using namespace std ;
bool input(char);
int main()
{
	char x ;
	bool a ;
	
	cout << "Please enter an alphabet :"<<endl;

	cin >> x ;

	a=input(x);

	{if (a=true)
		cout << "The alphabet inserted is a vowel \n:";
	  
	else 
		cout <<"The alphabet inserted is not a vowel \n:";
	}
	system ("pause");

		return 0;

}



bool input(char x)
{
	bool vowel ;

	switch (x)
	{
		case 'A':
		case 'a':
		case 'E':
		case 'e':			
		case 'I':
		case 'i':
		case 'O':
		case 'o':
		case 'U':
		case 'u':
			vowel = true ;

			break ;
		default: 
				vowel = false;
				break ;
	}
	return vowel;
}


This program should detect whether the character entered is a vowel , but the bool input (char x) function only return true value no matter what character I key in , please help .
Your if structure in the main() is incorrect

And while comparing use == and not = in if (a=true)
Sweet Jesus son of God you are correct ! Big thank you for you !
Topic archived. No new replies allowed.