C examples for String:String Function
Report the number of uppercase letters, the number of lowercase letters, and the number of other characters in the input.
#include <stdio.h> #include <ctype.h> int main(void){ int ch;//from w w w . ja v a 2 s. co m int uppercase_count = 0, lowercase_count = 0, other_count = 0; while ((ch = getchar()) != EOF){ if (isupper(ch)) uppercase_count++; else if (islower(ch)) lowercase_count++; else other_count++; } printf("Uppercase letters: %d\n", uppercase_count); printf("Lowercase letters: %d\n", lowercase_count); printf("Other: %d\n", other_count); return 0; }