Vowel or consonant what if user inputs a number?

i cannot understand else if logic how to do it
why it shows the message of consonant?


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.

In pseudo code you would write it like this:

If input is vowel then
print "Is vowel"
Else if input is consonant then
print "Is consonant"
Else
print "illegal input"

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;
}  
Your if statement syntax is not correct. You neglected to close the quotes after Vowel.
Topic archived. No new replies allowed.