C Program to count the number of uppercase lowercase


In this program, You will learn how to count a number of uppercase lowercase whitespaces and special symbols in c.


[email protected]#343 C++

Total number of uppercase alphabets = 2

Total number of lowercase alphabets = 3

Total number of digits =3

Total number of white spaces = 1

Total number of special symbols = 4

Example: How to count a number of uppercase lowercase in c.

#include<stdio.h>

int main(){

     char a[100];
     int i=0,up=0,lo=0;
     int dig=0,spc=0,sym=0;

     printf("Enter a String :");
     scanf("%[^\n]%*c", a); 

     while(a[i] != '\0'){
         i++;
     }

     for(int j = 0; j < i; j++){
         if(a[j] >= 65 && a[j] <= 90)
             up++;
         else if(a[j] >= 97 && a[j] <= 122)
             lo++;
         else if(a[j] >= 48 && a[j] <= 57)
             dig++;
         else if(a[j] == 32)
             spc++;
         else
             sym++;
     }
     printf("Uppercase :%d",up);
     printf("\nLowercase :%d",lo);
     printf("\nDigits %d:",dig);
     printf("\nWhite Spaces :%d",spc);
     printf("\nSpecial Symbols :%d",sym);

     return 0;
}

Output:

Enter a String :Xiith #$542 3
Uppercase :1
Lowercase :4
Digits 4:
White Spaces :2
Special Symbols :2