#include #include #include #include #include #include void input(int &input){ scanf("%d", &input); } void getString(char *str){ printf("input string: "); fgets(str, 100, stdin); } void countVowel(char *str){ int count = 0; int space = 0; int i; for(i = 0; i < strlen(str) - 1;i++){ if(str[i] == 'a' || str[i] == 'u' || str[i] == 'e' || str[i] == 'o' || str[i] == 'i'){ count++; } if(str[i] == ' '){ space++; } } printf("\nNumber of vowels: %d\nNumber of consonants: %zd", count, strlen(str) - count - space - 1); } void countChuHoaChuThuongVaSo(char *str){ int i; int countH = 0, countT = 0, countS = 0; for(i = 0; i < strlen(str); i++){ if(str[i] >= 'A' && str[i] <= 'Z'){ countH++; } if(str[i] >= 'a' && str[i] <= 'z'){ countT++; } if(str[i] >= '0' && str[i] <= '9'){ countS++; } } printf("\nNumber of chu hoa: %d\nNumber of chu thuong: %d\nNumber of chu so: %d", countH, countT, countS); } int main(){ printf("There are String Workshop:"); printf("\n1. Dem so nguyen am va phu am trong string."); printf("\n2. Dem so chu hoa,chu thuong va so trong string"); printf(""); char str[100]; int inp; printf("\nEnter a choice: "); input(inp); switch(inp){ case 1:{ //Dem so nguyen am va phu am trong string getString(str); countVowel(str); break; } case 2:{ //Dem so chu hoa,chu thuong va so trong string getString(str); countChuHoaChuThuongVaSo(str); break; } } return 0; }