write a program to input string and count how many capital and small letters are there. Explain in full methods.
Answers
int main() {
int upper = 0, lower = 0;
char ch[80];
int i;
printf("\nEnter The String : ");
gets(ch);
i = 0;
while (ch[i] != '') {
if (ch[i] >= 'A' && ch[i] <= 'Z')
upper++;
if (ch[i] >= 'a' && ch[i] <= 'z')
lower++;
i++;
}
printf("\nUppercase Letters : %d", upper);
printf("\nLowercase Letters : %d", lower);
return (0);
}
Answer:
Given a string, write a program to count the occurrence of Lowercase characters, Uppercase characters, Special characters, and Numeric values.
Examples:
Input : #GeeKs01fOr@gEEks07
Output :
Upper case letters : 5
Lower case letters : 8
Numbers : 4
Special Characters : 2
Input : *GeEkS4GeEkS*
Output :
Upper case letters : 6
Lower case letters : 4
Numbers : 1
Special Characters : 2