Reads input as a stream of characters until encountering EOF with isupper and islower functions. - C Data Type

C examples for Data Type:char

Introduction

Report the number of uppercase letters and the number of lowercase letters in the input.

Demo Code

#include <stdio.h>  
#include <ctype.h>  
int main(void)  
{  //from  www . j a  v  a  2 s. c o m
    int ch;  
    unsigned long uct = 0;  
    unsigned long lct = 0;  
    unsigned long oct = 0;  
      
    while ((ch = getchar()) != EOF)  
        if (isupper(ch))  
            uct++;  
        else if (islower(ch))  
            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;  
}

Result


Related Tutorials