C++ Program to Count Vowels, Consonants and White spaces
Write C++ Program to Count Vowels, Consonants and White spaces
// CPP Program to Count Vowels, Consonants and White spaces
#include <iostream>
#include <string.h>
using namespace std;
int main()
{
char S[] = "Hello and Well Come to CodeCrucks Folks";
int i = 0, count1 = 0, count2 = 0, count3 = 0;
while(S[i] != '\0')
{
if(S[i] == 'a' || S[i]== 'e' || S[i]=='i' || S[i]=='o' || S[i]=='u')
count1++;
else if(S[i]==' ')
count2++;
else
count3++;
i++;
}
cout << "Your String :--> " << S;
cout << "\n\nNumber of Vowels :--> " << count1;
cout << "\nNumber of Consonants :--> " << count3;
cout << "\nNumber of White Spaces :--> " << count2;
return 0;
}
Output:
Your String :--> Hello and WelCome to CodeCrucks Folks
Number of Vowels :--> 11
Number of Consonants :--> 21
Number of White Spaces :--> 6