Friday, April 5, 2019

C Program To Count Number Of Upper Case Letters and Lower Case Letters in a Given String

Program:-

#include<stdio.h>
#include<string.h>
int main()
{
int up=0,lr=0;
char ch[150];
printf("Enter the String:-\n");
scanf("%[^\n]",ch);
int i=0;
while(ch[i]!='\0')
{
if(ch[i] >= 'A' && ch[i] <= 'Z')
{
up++;
}
if(ch[i] >= 'a' && ch[i] <= 'z')
{
lr++;
}
i++;
}
printf("UpperCase Letters:%d\n",up);
printf("LowerCase Letters:%d",lr);
return(0);
}

output:-



No comments:

Post a Comment