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

Ghanendra Yadav

Ghanendra Yadav

Hello, I Am Ghanendra Yadav Owner of This Blog, I am professional Blogger and Programmer. I Love Programming, Logo Making, And Banner Designing. My Highest Qualification is MCA From NIT Warangal. You Can Find Me On Social Media Through Below Link And If You Have Any Query Related To Programming And Other Subject Comment Below or You Can Mail Me I Will Try To Answer Within 24 Hours Email:- yghanendra@student.nitw.ac.in

Find me on Social Media

Facebook | Twitter | Google+ | RSS Feed


  1. Anonymous4/08/2016

    Explore 100+ niche topics to improve skills, learning & knowledge Click Here

  2. Explore 100+ niche topics in marketing,startups,finance,healthcare,sexual problem,legal,laravel,web development,logo,htaccess and more to improve skills, learning & knowledge Click Here

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