Write a c program to count number of uppercase and lowercase letters in a given string.The string may be word or a sentence
Answers
Answered by
1
Answer:
Explanation:
#include <stdio.h>
void main()
{
char str[100];
int cntLw,cntUp;
int count;
//assign all counters to zero
countL=countU=0;
printf("Enter a string: ");
gets(str);
for(count=0;str[count]!=NULL;count++)
{
if(str[count]>='A' && str[count]<='Z')
cntUp++;
else if(str[count]>='a' && str[count]<='z')
cntLw++;
}
printf("Total Upper case characters: %d, Lower Case characters: %d",cntUp,cntLw);
return 0;
}
Similar questions