C++ and C Program to Find the Number of Vowels, Digits, Consonants and White Spaces in a String with flowchart
C++ and C Program to Find the Number of Vowels, Digits, Consonants and White Spaces in a String with flowchart
In this tutorial, we will learn about the followings;
- Flowchart of a program to Find the Number of Vowels, Digits, Consonants and White Spaces in a String
- C++ Program to Find the Number of Vowels, Digits, Consonants and White Spaces in a String
- C Program to Find the Number of Vowels, Digits, Consonants and White Spaces in a String
Flowchart of a program to Find the Number of Vowels, Digits, Consonants and White Spaces in a String
C++ Program to Find the Number of Vowels, Digits, Consonants and White Spaces in a String
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
//Find Number of Vowels, Consonants, Digits, Spaces in a String #include<stdio.h> #include<iostream> #include<conio.h> using namespace std; int main() { char Words[500]; int number; int vowel_words; int Consonants; int ch_01; int digit_words; int spaces; int wl_01; wl_01=0; vowel_words=0; Consonants=0; ch_01=0; digit_words=0; spaces=0; cout<<"please enter a sentences of your on choose: "; cout<<"\n"; gets(Words); for(number=0;Words[number]!='\0';++number) { if(Words[number]=='a' || Words[number]=='e' || Words[number]=='i' || Words[number]=='o' || Words[number]=='u' || Words[number]=='A' || Words[number]=='E' || Words[number]=='I' || Words[number]=='O' || Words[number]=='U') ++vowel_words; else if((Words[number]>='a'&& Words[number]<='z') || (Words[number]>='A'&& Words[number]<='Z')) ++Consonants; else if(Words[number]>='0'&& Words[number]<='9') ++digit_words; else if (Words[number]==' ') ++spaces; } cout<<"How many vowels are present in the sentences? "<<vowel_words; cout<<"\n"; cout<<"How many Consonants are present in the sentences? "<<Consonants; cout<<"\n"; cout<<"How many Digital numbers are present in the sentences? "<<digit_words; cout<<"\n"; cout<<"How many blanck spaces are present in the sentences?"<<spaces; getch(); } |
Output
C Program to Find the Number of Vowels, Digits, Consonants and White Spaces in a String
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
//Find Number of Vowels, Consonants, Digits, Spaces in a String #include<stdio.h> #include<conio.h> int main() { char Words[500]; int number; int vowel_words; int Consonants; int ch_01; int digit_words; int spaces; int wl_01; wl_01=0; vowel_words=0; Consonants=0; ch_01=0; digit_words=0; spaces=0; printf("please enter a sentences of your on choose: "); printf("\n"); gets(Words); for(number=0;Words[number]!='\0';++number) { if(Words[number]=='a' || Words[number]=='e' || Words[number]=='i' || Words[number]=='o' || Words[number]=='u' || Words[number]=='A' || Words[number]=='E' || Words[number]=='I' || Words[number]=='O' || Words[number]=='U') ++vowel_words; else if((Words[number]>='a'&& Words[number]<='z') || (Words[number]>='A'&& Words[number]<='Z')) ++Consonants; else if(Words[number]>='0'&& Words[number]<='9') ++digit_words; else if (Words[number]==' ') ++spaces; } printf("How many vowels are present in the sentences? %d",vowel_words); printf("\n"); printf("How many Consonants are present in the sentences? %d",Consonants); printf("\n"); printf("How many Digital numbers are present in the sentences? %d",digit_words); printf("\n"); printf("How many blanck spaces are present in the sentences ? %d ",spaces); getch(); } |
Output