C program to input any string and count upper case and lower case char.
#include<stdio.h>
#include<conio.h>
void main( )
{
char str[20]; int i, u=0, l=0;
clrscr( );
printf("enter any string ");
scanf("%s",str);
i=0;
while(str[i]!='\0')
{
if(str[i]>=65 && str[i]<=90)
{
u=u+1;
}
if(str[i]>=97 && str[i]<=122)
{
l=l+1;
}
i=i+1;
}
printf("Total Upper case is %d\n",u);
printf("Total Upper case is %d\n",u);
getch( );
}
0 Comments