Tuesday, 22 March 2016

C Program For Find Number of Vowels, Consonants, Digits and White Space Character

#include<stdio.h>

int main()
{
    char line[150];
    int i,v,c,ch,d,s,o;
 
    o=v=c=ch=d=s=0;
    printf("Enter a line of string:\n");
 
    gets(line);
    for(i=0;line[i]!='\0';++i)
    {
        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')
            ++v;
        else if((line[i]>='a'&& line[i]<='z') || (line[i]>='A'&& line[i]<='Z'))
            ++c;
        else if(line[i]>='0'&&c<='9')
            ++d;
        else if (line[i]==' ')
            ++s;
    }

    printf("Vowels: %d",v);
    printf("\nConsonants: %d",c);
    printf("\nDigits: %d",d);
    printf("\nWhite spaces: %d",s);
    return 0;
}

Output:-

www.programmingwithbasics.com

3 comments:
Write comments
  1. Explore 100+ niche topics to improve skills, learning & knowledge Click Here

    ReplyDelete
  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

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

    ReplyDelete

Recommended Posts × +