Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Include definitions for C Runtime Library functions used in this program
- #include <stdio.h> //The standard I/O functions
- //-------------------------------------------------------------------------------
- //This is the main function, invoked by the C Runtime (CRT) to start the program
- //-------------------------------------------------------------------------------
- int main(void) {
- int c, totalCharacters, upperCase, lowerCase, vowels, consonants, digits, capacity;
- c = totalCharacters = upperCase = lowerCase = vowels = consonants = digits = 0;
- capacity = 500;
- char stringArray[capacity];
- gets(stringArray);
- for(i = 0; stringArray[i] != NULL; i++){
- if(stringArray[i]=='a' || stringArray[i]=='e' || stringArray[i]=='i' ||
- stringArray[i]=='o' || stringArray[i]=='u')
- {
- ++vowels;
- ++lowerCase;
- ++totalCharacters;
- }
- else if(stringArray[i]=='A' || stringArray[i]=='E' || stringArray[i]=='I' ||
- stringArray[i]=='O' || stringArray[i]=='U')
- {
- ++vowels;
- ++upperCase;
- ++totalCharacters;
- }
- else if((stringArray[i]>='a') || stringArray[i]<='z')
- {
- ++consonants;
- ++lowerCase;
- ++totalCharacters;
- }
- else if((stringArray[i]>='A') || stringArray[i]<='Z')
- {
- ++consonants;
- ++upperCase;
- ++totalCharacters;
- }
- else if((stringArray[i]>='0') || stringArray[i]<='9')
- {
- ++digits;
- ++totalCharacters;
- }
- else
- {
- ++totalCharacters;
- }
- }
- printf("upper-case: %d\n", upperCase);
- printf("lowerCase-case: %d\n", lowerCase);
- printf("vowels: %d\n", vowels);
- printf("consonants: %d\n", consonants);
- printf("digits: %d\n", digits);
- printf("total: %d\n", totalCharacters);
- }
Add Comment
Please, Sign In to add comment