In a vowel check program whether user inputs a vowel or consonant what if a user inputs a number and why it shows the message of consonant?how can i show the message"you have entered wrong input" kindly help i am new
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include <iostream.h>
#include <conio.h>
int main(){
char alpha;
clrscr();
cout<<"Enter an alphabet: ";
cin>>alpha;
if(alpha=='a'||alpha=='A'||alpha=='e'||alpha=='E'||alpha=='i'||alpha=='I'||alpha=='o'||alpha=='O'||alpha=='u'||alpha=='U')
cout<<alpha<<"is a Vowel;
else
cout<<alpha<<"consonant";
getch();
return 0;
}
Because you check only for two possibilities. If it is not a vowel than it is a consonant.
To solve the problem you need to check for a third option - i.e. an illegal input.
The logic to do is actually not so difficult.
In pseudo code you would write it like this:
1 2 3 4 5 6
If input is vowel then
print "Is vowel"
Else if input is consonant then
print "Is consonant"
Else
print "illegal input"
I hope you can fix your code, otherwise post again.