Advertisement
ZinedinZidan

vcdwo

Dec 3rd, 2019
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.98 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3. int main()
  4. {
  5.     char str[100],ch;
  6.     int i,vowel,consonant,digit,word,other;
  7.     printf("Enter a string : ");
  8.     gets(str);
  9.     i=vowel=consonant=digit=word=other=0;
  10.     while((ch=str[i])!='\0')
  11.     {
  12.         if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u'||ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U')
  13.         {
  14.             vowel++;
  15.         }
  16.         else if(ch>='a'&&ch<='z'||ch>='A'&&ch<='Z')
  17.         {
  18.             consonant++;
  19.         }
  20.         else if(ch>='0'&&ch<='9')
  21.         {
  22.             digit++;
  23.         }
  24.         else if(ch==' ')
  25.         {
  26.             word++;
  27.         }
  28.         else
  29.         {
  30.             other++;
  31.         }
  32.  
  33.         i++;
  34.     }
  35.     word++;
  36.    
  37.  
  38.     printf("Number of vowels = %d\n",vowel);
  39.     printf("Number of consonants = %d\n",consonant);
  40.     printf("Number of digits = %d\n",digit);
  41.     printf("Number of words = %d\n",word);
  42.     printf("Number of others = %d\n",other);
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement