C program to count number of Uppercase and Lowercase letters

C program to count number of Uppercase and Lowercase letters:
If you are using any software then below program will not give an error, but if you are using TURBO C then you have to make some changes like: void main() and some function like clrscr() or getch().

#include<stdio.h>

main()
{
   int upper=0,lower=0;
   char ch[80];
   int i=0;

   printf("Enter The String : ");
   gets(ch);

   while(ch[i] != '\0')
    {
      if(ch[i] >= 'A' && ch[i] <= 'Z')
         upper++;
      if(ch[i] >= 'a' && ch[i] <= 'z')
         lower++;
      i++;
    }

   printf("\nLetters in Uppercase : %d",upper);
   printf("\nLetters in Lowercase : %d",lower);
}

OUTPUT:

Enter The String : BaronTuts

Letters in Uppercase : 2
Letters in Lowercase : 7

 

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.