sivan_iut

Untitled

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