C Program To Count Vowel,consonant, Special Character & Digits

//Program to count vowel,consonant, special character & digits
#include<stdio.h>
#include<string.h>
int main()
{
int i, vowel=0, cons=0, digit=0, sp=0, digits=0;
char str[100];
printf("Enter string:\n");
gets(str);
for (i=0;i<strlen(str);i++)
{
if (str[i]=='A'||str[i]=='a'||str[i]=='e'||str[i]=='E'||str[i]=='i'||str[i]=='I'||str[i]=='o'||str[i]=='O'||str[i]=='u'||str[i]=='U')
{
vowel++;
}
else if ((str[i]>=0&&str[i]<=47)||(str[i]>=58&&str[i]<=64)||(str[i]>=91&&str[i]<=96)||(str[i]>=123&&str[i]<=127))
{
sp++;
}
else if (str[i]>=48&&str[i]<=57)
{
digits++;
}

}
cons=strlen(str)-vowel-sp-digits;
printf("vowel=%d\nConsonant=%d\nDigits=%d\n)Special Character=%d\n",vowel,cons,digits,sp);
}





OUTPUT

C program to count vowel,consonant, special character and digits

Share To:

Arogya Thapa Magar

Post A Comment:

0 comments so far,add yours