C Program to Count Vowels, Consonants, Digits and Spaces in Given String

Problem:- C program to count the number of vowels, consonants and so on or C Program to Count Vowels, Consonants, Digits and Spaces in Given String or Find Number of Vowels, Consonants, Digits and White Space Characters or C Programming Notes: Counting vowels, consonants, digits, special character or C Program to Count words, vowels, letters, digits, spaces, Characters or Program to Find the Number of Vowels, Consonants, Digits and Whitespace in a String in C or Count the number of vowels, consonants, digits etc or C program to Count Vowels, Consonants, Digits, Spaces from String.

Check This:- Hacker rank solution for Strings, Classes, STL, Inheritance in C++.

Explanation:- for Counting the vowels, constant, digits and white space in c is very simple we have to just put an if else condition for each query. As we can see that there are 4 query(vowels, constant, digits and white space) so we have 4 counter separate for each of them and for finding the vowels in a string or sentence if simple just put the 5 character in lower and upper case and compare with the input string if any character matches then increase the vowels counter and same for constant and digit, for a single iteration of a string any one of the counters should be increased. last counter for white space, and at the end print the all 4 counters values, total counter values is equal to the size of the string.

Also Check:- Geeksforgeeks solution for School, Basic, Easy, Medium, Hard in C++.

Extreme Recommended:- Like our Facebook Page or Join our Facebook Group and Google plus Community for up-to-date for a new post or if you have any Query you can ask there with lots of coders also suggest to your Friends to join and like our page.



int main()
/*Visit - www.programmingwithbasics.com*/
    printf("\nVisit - www.programmingwithbasics.com");
    char line[1000];
    int i, v, c, ch, d, s, o;
    o = v = c = ch = d = s = 0;
    printf("\n\nEnter a Line of String: \n\n");
        if(line[i]=='a' || line[i]=='e' || line[i]=='i' || line[i]=='o' || line[i]=='u' || line[i]=='A' || line[i]=='E' || line[i]=='I' || line[i]=='O' || line[i]=='U')
        else if((line[i]>='a'&& line[i]<='z') || (line[i]>='A'&& line[i]<='Z'))
        else if(line[i]>='0'&&c<='9')
        else if (line[i]==' ')
    printf("\n\nOutput Is Below\n\n");

    printf("\n\nTotal Number of Vowels Are: %d",v);
    printf("\nTotal Number of Consonants Are: %d",c);
    printf("\nTotal Number of Digits Are: %d",d);
    printf("\nTotal Number of White spaces Are: %d\n\n",s);
    return 0;


C Program to Count Vowels, Consonants, Digits and Spaces in Given String

You May Also See

1. C Program For Remove All Vowels From A String

Previous Post
Next Post

post written by:

Hi, I’m Ghanendra Yadav, SEO Expert, Professional Blogger, Programmer, and UI Developer. Get a Solution of More Than 500+ Programming Problems, and Practice All Programs in C, C++, and Java Languages. Get a Competitive Website Solution also Ie. Hackerrank Solutions and Geeksforgeeks Solutions. If You Are Interested to Learn a C Programming Language and You Don't Have Experience in Any Programming, You Should Start with a C Programming Language, Read: List of Format Specifiers in C.
Follow Me

1 comment:

  1. Welcome Bro To My Programming World I Hope You Will Enjoy Here