Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- char str[100];
- int countAlphabet,countSpecialChar,countSpaces;
- int counter;
- countAlphabet=countSpecialChar=countSpaces=0; //all counters to zero
- printf("Enter a string: ");
- gets(str);
- for(counter=0;str[counter]!=NULL;counter++)
- {
- if((str[counter]>='A' && str[counter]<='Z')||(str[counter]>='a' && str[counter]<='z'))
- countAlphabet++;
- else if(str[counter]==' ')
- countSpaces++;
- else
- countSpecialChar++;
- }
- printf("Alphabets: %d \nSpaces: %d \nSpecial Characters: %d",countAlphabet,countSpaces,countSpecialChar);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement