C Program to count number of uppercase lowercase


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


Code@#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 number of uppercase lowercase in c

Run it Now
#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 :");
     fgets(a,100,stdin);

     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("\nUppercase :%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 :John #$245 4
Uppercase :1
Lowercase :3
Digits 4:
White Spaces :2
Special Symbols :2