Advertisement
Nabil-Ahmed

Untitled

Jul 26th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.93 KB | None | 0 0
  1. //count v,c,d,s//
  2. #include<stdio.h>
  3. int main()
  4. {
  5.     char str[150];
  6.     int i, vowels, consonants, digits, spaces;
  7.     vowels = consonants = digits = spaces= 0;
  8.  
  9.     printf("Enter string: ");
  10.     scanf("%[^\n]",str);
  11.  
  12.     for(i=0; str[i]!='\0'; i++)
  13.     {
  14.         if(str[i]=='a' || str[i]=='e' || str[i]=='i' || str[i]=='o' || str[i]=='u' || str[i]=='A' || str[i]=='E' || str[i]=='I' || str[i]=='O' || str[i]=='U')
  15.         {
  16.             vowels++ ;
  17.         }
  18.         else if((str[i]>='a' && str[i]<='z') || (str[i]>='A' && str[i]<='Z'))
  19.         {
  20.             consonants++ ;
  21.         }
  22.         else if(str[i]>='0' && str[i]<='9')
  23.         {
  24.             digits++ ;
  25.         }
  26.         else if (str[i]==' ')
  27.         {
  28.             spaces++ ;
  29.         }
  30.     }
  31.     printf("Vowels: %d\n",vowels);
  32.     printf("Consonants: %d\n",consonants);
  33.     printf("Digits: %d\n",digits);
  34.     printf("Space: %d",spaces);
  35.  
  36.     return 0;
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement