C Program to Count Vowels, Consonants and White spaces
Write C Program to Count Vowels, Consonants and White spaces
// C Program to Count Vowels, Consonants and White spaces #include <stdio.h> #include <string.h> int main() { char S[] = "Hello and Wel 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++; } printf("Your String :--> %s", S); printf("\n\nNumber of Vowels :--> %d ", count1); printf("\nNumber of Consonants :--> %d ", count3); printf("\nNumber of White Spaces :--> %d ", 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