Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //count v,c,d,s//
- #include<stdio.h>
- int main()
- {
- char str[150];
- int i, vowels, consonants, digits, spaces;
- vowels = consonants = digits = spaces= 0;
- printf("Enter string: ");
- scanf("%[^\n]",str);
- for(i=0; str[i]!='\0'; i++)
- {
- 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')
- {
- vowels++ ;
- }
- else if((str[i]>='a' && str[i]<='z') || (str[i]>='A' && str[i]<='Z'))
- {
- consonants++ ;
- }
- else if(str[i]>='0' && str[i]<='9')
- {
- digits++ ;
- }
- else if (str[i]==' ')
- {
- spaces++ ;
- }
- }
- printf("Vowels: %d\n",vowels);
- printf("Consonants: %d\n",consonants);
- printf("Digits: %d\n",digits);
- printf("Space: %d",spaces);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement