C Program to Find the Number of Vowels, Consonants, Digits and White space in a String

To understand this example, you should have knowledge of following C programming topics:

This program takes a string from user and finds the total number of vowels, consonants, digits and white space present in that string.

Source Code to Find Number of Vowels, Consonants, Digits and White Space Character

int main(){
    char line[150];
    int i,v,c,ch,d,s,o;
    printf("Enter a line of string:\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("Vowels: %d",v);
    printf("\nConsonants: %d",c);
    printf("\nDigits: %d",d);
    printf("\nWhite spaces: %d",s);
    return 0;


Enter a line of string:
This program is easy 2 understand
Vowels: 9
Consonants: 18
Digits: 1
White spaces: 5