C examples for Data Type:char
Reads input as a stream of characters until encountering EOF without using isupper and islower functions.
#include <stdio.h> #include <ctype.h> int main(void) { /*from w w w .jav a2s . c om*/ int ch; unsigned long uct = 0; unsigned long lct = 0; unsigned long oct = 0; while ((ch = getchar()) != EOF) { if (ch >= 'A' && ch <= 'Z') uct++; else if (ch >= 'a' && ch <= 'z') lct++; else oct++; } printf("%lu uppercase characters read\n", uct); printf("%lu lowercase characters read\n", lct); printf("%lu other characters read\n", oct); return 0; }