C++ Program to Find the Number of Vowels, Consonants, Digits and White Spaces in a String

C++ Program to Find the Number of Vowels, Consonants, Digits and White Spaces in a String : In this example, if…else statement is used to check whether an alphabet entered by the user is a vowel or a constant.Five alphabets a, e, i, o and u are known as vowels. All other alphabets except these 5 alphabets are known are consonants.

C++ Program to Find the Number of Vowels, Consonants, Digits and White Spaces in a String

#include<iostream>
#include<conio.h>
using namespace std;
main()
{
char ch;
cout<<"Enter an alphabet:";
cin>>ch;
if(ch=='a'||ch=='A'||
ch=='e'||ch=='E'||
ch=='i'||ch=='I'||
ch=='o'||ch=='O'||
ch=='u'||ch=='U')
cout<<"it is a vowel";
else
cout<<"it is a consonant";
getch();
}

Output of Program

Enter an alphabet:b
it is a consonant

Enter an alphabet:i
it is a vowel